Cursor

Introduced in Java 1.1, the Cursor class provides the different cursors that can be associated with a Component. Previously, cursors could only be associated with a whole Frame. Now any component can use fancy cursors when the user is interacting with the system.

To change the cursor, a component calls its setCursor() method; its argument is a Cursor object, which is defined by this class.

NOTE:

There is still no way to assign a user-defined cursor to a Component. You are restricted to the 14 predefined cursors.

Cursor Constants

The following is a list of Cursor constants. The cursors corresponding to the constants are shown in Figure 5.6.

public final static int DEFAULT_CURSOR
public final static int CROSSHAIR_CURSOR
public final static int TEXT_CURSOR
public final static int WAIT_CURSOR
public final static int HAND_CURSOR
public final static int MOVE_CURSOR
public final static int N_RESIZE_CURSOR
public final static int S_RESIZE_CURSOR
public final static int E_RESIZE_CURSOR
public final static int W_RESIZE_CURSOR
public final static int NE_RESIZE_CURSOR
public final static int NW_RESIZE_CURSOR
public final static int SE_RESIZE_CURSOR
public final static int SW_RESIZE_CURSOR

Figure 5.6: Standard Java cursors

[Graphic: Figure 5-6]

Cursor Methods

Miscellaneous methods