Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Freeze the GUI on a button click process.

 
Melki Joe
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

I am having a GUI where i will be having four or five buttons more than that i will be having a tree also. For each button there will be an action called, on the same time in the tree also on selecting each node of the tree an action will be performed. But for me the requirement is when I click one button then the whole GUI should freeze so that no other action can be performed until the process of this buttons action is performed.

Kindly give me an idea regarding this.

Thank you.
 
Josh Britton
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about just using a boolean as a flag? Actions first check the boolean. If the boolean indicates no current action, the new action toggles the boolean. When the new action is done, it toggles the boolean back.

However, this doesn't give the user any visual cue regarding the 'freeze.' I suppose every time you toggle the flag boolean, you can also toggle all of the enabled properties of your components. Does anyone have a simple way of disabling a Container with all of its children, children's children, etc.? The best I can think of is a recursive dive.
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You really do not need to do anything.
All code in the action performed is executed on the EDT which effectively freezes the UI anyway.
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although that also includes repainting.

If you want to do the work in a separate thread (e.g. using SwingWorker), you can just disable all other controls, and re-enabled them after the thread has finished.
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just another cross poster.
http://www.java-forums.org/awt-swing/13966-perform-one-action-time.html
 
Melki Joe
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any condition that i should not post my queries in any other forums?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Is there any condition that i should not post my queries in any other forums?

none whatsoever - you're free to do as you please.

from my point of view, occasionally I've spent quite some time putting
together a sample program to demonstrate a solution (easier than trying to explain it),
then clicked on another forum, only to see the same question answered some
hours earlier.

I do enjoy wasting my time like that - just trying to help someone.

like you, I'm free to do as I please, and I choose never to provide
solutions to known cross-posters.

All that aside, cross-posting, done properly benefits everyone.
 
Melki Joe
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply. What could be the solution to post the same topic in two forums so that I could get more suggestions.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the correct way is to post in a single forum first (here, sun, other)
give it a bit of time for a response
if no response, or responses don't work/whatever, then
post in a second forum, but start by mentioning that you've already posted at...,
and provide a link to your first post.

now go back to your first post and mention you've now also posted at ...,
and provide a link to the second post.

this way, anyone can click the links and see what the total response is.

anyone with a similar problem, searching (e.g.) javaranch, might not have the
solution posted here, but it might be posted in the link at (e.g.) sun forum,
and vice versa
 
Melki Joe
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for your kind suggestion and solution.
[ December 06, 2008: Message edited by: Melki Joe ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic