How can I change the cursor shape?
Any graphical component is capable of changing the mouse cursor. As the user moves the cursor over the component, the cursor will change. Setting a new cusor type is easy - every subclass of java.awt.Component has a setCursor method. Individual components, or even applets can specify their own cursor.
// Create an instance of java.awt.Cursor Cursor c = new Cursor ( Cursor.WAIT_CURSOR ); // Create a frame to demonstrate use of setCursor method Frame f = new Frame("Cursor demo"); f.setSize(100,100); // Set cursor for the frame component f.setCursor (c); // Show frame f.show();
There isn't a "global" cursor type, so this means that you can have different cursors for different components. But just remember - using cursors inappropriately will make it difficult for users, so don't put an hourglass wait component unless you actually want the user to wait! A full list of cursor types is available from the documentation for java.awt.Cursor.