well Lucky, In JDK 1.0.2 only the awt Frame could change its Cursor. With the advent of JDK 1.1 the Cursor manipulation has been move to the Component clss. Now all Components have access to the Cursor class.
Swing has many components that can be used in place of components in the AWT (e.g. JFrame instead of Frame, JButton instead of Button, JApplet instead of Applet, JPanel instead of Panel). It also has many components that don't exist in the AWT (e.g. tool tips, toolbars, and progress bars). However Swing relies on the underlying AWT being there.
The Swing toolkit allows the creation of GUI's that are every bit as sophisticated as native code toolkits like MFC -- with the Java advantage that they run on every platform. The pluggable look and feel means that they can have the same appearance on every platform, or you can choose to have it look like Windows on a PC, like Motif on a Unix box, etc, just as the user chooses.
You could change your Cursor to a WAIT_CURSOR for each Component. This could be time-consuming. You could have a potentially large number of Components. With the advent of the JFC Swing, there is a mechanism to change the Cursor over the entire Window regardless of the number of components. The Swing component JFrame has a method:
public void setGlassPane(Component glassPane)
which sets an awt Component as the 'glassPane' for the JFrame.
This Component will cover the entire JFrame's visible user accessible (when visible), area excluding the border set by the underlying windowing system. With the 'glassPane' Component you can set the 'WAIT_CURSOR' over an entire JFrame, prohibiting user input (the 'glassPane' Component gets all user input) and blocking the user until your 'other' processing is complete.
NOTE: You must spawn a Thread to accomplish your 'other' work if you want to see the WAIT_CURSOR while the 'other' processing is happening. When the 'other' work is being accomplished, the 'glassPane' is visible with a WAIT_CURSOR and gobbling up all user input. When the 'other' work is finished, the Thread uses your waitCursor() method to hide your 'glassPane' until its needed again.
For more information , please do visit source site:
http://software.allindi ansite.com/jfaqs/swing.html
Hope it will help you out.
Answered by
Uttam
, an ibibo Master,
at
7:45 PM on May 16, 2008