File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hwo to use system cursors like the hourglass

 
Jay Mistry
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As soon as the procedure starts use
this.setCursor(Cursor.WAIT_Cursor)
& at the end use
this.setCursor(Cursor.DEFAULT_Cursor)
 
Edward Liu
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic