HOW TO

Display a Wait-Cursor while the data is being fetched and displayed on the Map

Last Published: April 25, 2020

Summary

Instructions provided describe how to display a custom Wait-Cursor, such as hour-glass, while data is 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.

  1. Instantiate a DisplayListener object and override its start and finish methods as follows:

    Code:
    public class CursorTest extends JFrame{

    private Map map1;
    private 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);

    }
    };
    ...


    Note:
    Do not create the DisplayListener object as a local variable or with a weak reference; otherwise, listener instances may be garbage-collected immediately.

  2. Set a custom Wait-Cursor for the Map.

    Code:

    map1.setWaitingCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));


    Note:
    Call this method only if displaying a custom cursor. WAIT_CURSOR (hour-glass) will be selected by default.

  3. Add the DisplayListener object to the Map.

    Code:

    map1.addDisplayListener(dl);

Article ID:000005878

Software:
  • Legacy Products

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options