阅读:2202回复:0
a Wait-Cursor
HowTo: Display a Wait-Cursor while the data is being fetched and displayed on
Summary Instructions provided describe how to display a custom Wait-Cursor, such as hour-glass, while data are being accessed and displayed in a Map component. Procedure Create a custom DisplayListener and override the start and finish methods. The start method should include a call to aMap.setWaiting(true) when a display event starts, such as redraw, change the Map extent, and set a layer's visibility. The finish method should include a call to aMap.setWaiting(false) when the display event finishes. Instantiate a DisplayListener object and override its start and finish methods as follows: public class CursorTest extends JFrame{ private com.esri.mo.ui.bean.Map map1; private com.esri.mo.ui.bean.Layer layer1; private JPanel contentPane; JSplitPane jSplitPane1 = new JSplitPane(); BorderLayout borderLayout1 = new BorderLayout(); ZoomPanToolBar zoomPanToolBar1 = new ZoomPanToolBar(); Toc toc1 = new Toc(); DisplayListener dl; public CursorTest() { dl = new DisplayAdapter(){ public void start(DisplayEvent e) { map1.setWaiting(true); } public void finish(DisplayEvent e) { map1.setWaiting(false); } }; ... Do not create the DisplayListener object as a local variable or with a weak reference; otherwise, listener instances may be garbage-collected immediately. Set a custom Wait-Cursor for the Map. map1.setWaitingCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); Call this method only if displaying a custom cursor. WAIT_CURSOR (hour-glass) will be selected by default. Add the DisplayListener object to the Map. map1.addDisplayListener(dl); |
|