Java Business RIA redefined!
The moose likes Swing / AWT / SWT / JFace and the fly likes Freeze the GUI on a button click process. The Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "Freeze the GUI on a button click process." Watch "Freeze the GUI on a button click process." New topic
Author

Freeze the GUI on a button click process.

Melki Joe
Greenhorn

Joined: Aug 29, 2008
Posts: 24
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

Joined: Nov 26, 2008
Posts: 24
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
Bartender

Joined: Jul 26, 2007
Posts: 4838
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.

work is the scourge of the drinking class
Rob Prime
Bartender

Joined: Oct 27, 2005
Posts: 11146
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.

SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Darryl Burke
Ranch Hand

Joined: May 03, 2008
Posts: 442
Just another cross poster.
http://www.java-forums.org/awt-swing/13966-perform-one-action-time.html

luck, db
Melki Joe
Greenhorn

Joined: Aug 29, 2008
Posts: 24
Is there any condition that i should not post my queries in any other forums?
Michael Dunn
Rancher

Joined: Jun 09, 2003
Posts: 3360
> 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

Joined: Aug 29, 2008
Posts: 24
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
Rancher

Joined: Jun 09, 2003
Posts: 3360
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

Joined: Aug 29, 2008
Posts: 24
Thank you very much for your kind suggestion and solution.
[ December 06, 2008: Message edited by: Melki Joe ]
 
jQuery in Action, 2nd edition
 
subject: Freeze the GUI on a button click process.
 
aspose file troubles

.