Saturday, August 04, 2007

Changing the Cursor

The component's cursor property can be changed at any time by calling Component.setCursor() in Java. See the java.awt.Cursor class for available predefined cursor shapes.
// Create a component
Component component = new Button("OK");

// By default, the component's cursor is Cursor.DEFAULT_CURSOR
Cursor cursor = component.getCursor();

// Change the component's cursor to another shape
component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

No comments: