This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

What is the expected behaviour of the cursor when a dialog appears?  RSS feed

 
Ranch Hand
Posts: 590
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the expected behaviour of the cursor state when a JDialog appears?

I have set up my application to set the cursor to the WAIT_CURSOR state when I am carrying out a long operation. Then I set it back to the DEFAULT_CURSOR state when the operation is complete.

If the operation does not complete successfully an exception is thrown then I display a JDialog with a user friendly error message.

When the JDialog appears my code to set the cursor state back to DEFAULT_CURSOR will not have excecuted yet as it is in a finally block. I was worried that my cursor would stay in the WAIT_CURSOR state and thus preventing the user from dismissing the JDialog that popped up or confusing them.

However I happy to see that the JDialog appearing automatically caused my cursor to go back to the DEFAULT_CURSOR state. So my question is - can I rely on the JDialog always setting my cursor back to the DEFAULT_CURSOR state? Or should I put putting in some code to set it back to DEFAULT_CURSOR before I show JDialog.

I have provided some sample code below that outlines my current set up. Simply run the code, click on the button, you will see the hour glass appear for 2 seconds, then a JDialog will appear. You can see from the console output that my code to set the cursor back to the DEFAULT_CURSOR state has not executed at this stage. It does not execute until you dismiss the JDialog.

 
Sheriff
Posts: 21450
95
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hasn't nobody told you not to call Thread.sleep on the Event Dispatcher Thread? See Concurrency in Swing for more details.
 
Sean Keane
Ranch Hand
Posts: 590
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Spoor wrote:Hasn't nobody told you not to call Thread.sleep on the Event Dispatcher Thread? See Concurrency in Swing for more details.



Not sure how this helps? What I am looking for help on is...

What is the expected behaviour of the cursor state when a JDialog appears?

Can I rely on the JDialog always setting my cursor back to the DEFAULT_CURSOR state?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!