The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.awt  [78 examples] > Cursors  [1 examples]

e574. Changing the Cursor

A component has a cursor property which controls the shape of the cursor when the cursor is above the component. The component's cursor property can be changed at any time by calling Component.setCursor(). See the Cursor class for available predefined cursor shapes.
    // Create a component
    Component comp = new Button("OK");
    
    // By default, the component's cursor is Cursor.DEFAULT_CURSOR
    Cursor cursor = comp.getCursor();
    
    // Change the component's cursor to another shape
    comp.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

 Related Examples

See also: Colors    Components    Containers    Drawing    Events    Focus    Frames    GridBagLayout    Images    Shapes    Simulating Events    Text    The Screen   


© 2002 Addison-Wesley.