• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

hwo to use system cursors like the hourglass

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
It's feeding time! Give me the food you were going to give to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic