wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes hwo to use system cursors like the hourglass Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "hwo to use system cursors like the hourglass" Watch "hwo to use system cursors like the hourglass" New topic
Author

hwo to use system cursors like the hourglass

Jay Mistry
Greenhorn

Joined: May 19, 2001
Posts: 16
Hi,
how can I use the system cursors in my java swing application, plus when I click on a button or menu item it sticks around until the next window is ready to be displayed and it goes away right before the window opens - how do I stop this and use the hourglass or some other system cursor to let the user know that something is happening?
thank you very much
------------------

[This message has been edited by Jay Mistry (edited May 24, 2001).]
Deepal Mehta
Greenhorn

Joined: May 28, 2001
Posts: 6
As soon as the procedure starts use
this.setCursor(Cursor.WAIT_Cursor)
& at the end use
this.setCursor(Cursor.DEFAULT_Cursor)
Edward Liu
Greenhorn

Joined: May 29, 2001
Posts: 2
Howdy,
The prior code, while functional, is deprecated. The following will compile in Java 1.3 without warnings:
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR))
and
this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR).
Note that these calls simply change the cursor shape, however. This does NOTHING to lock out mouse or key actions. I imagine you could do that by setting a "state" variable in the class and then adding stuff to mouse and key listeners that ignore input if the state variable is set. There has to be a better way to tell Java that a Swing component is busy, but it seems nicely buried amongst all the other stuff Swing does, and none of the texts I've ever seen seem to talk about how to do that.
-- Ed
Colleen Casey
Greenhorn

Joined: Apr 24, 2001
Posts: 9
Edward,
To lock out all keyboard events, you will need to set the glasspane.


You can do this with:


JComponent gp = (JComponent) getGlassPane();
gp.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
gp.setVisible(true);


To turn off the glasspane, just reset the cursor to default and set visible to false.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hwo to use system cursors like the hourglass
 
Similar Threads
maximum opened cursors exeeded
Help providing visual confirmation
How to do Hourglass cursor in Javascript?
Two Images on the Same Panel
Q about JDBC driver classes: how many open cursors