This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Freeze the GUI on a button click process. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
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
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10172
    
    8

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.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Just another cross poster.
http://www.java-forums.org/awt-swing/13966-perform-one-action-time.html


luck, db
There are no new questions, but there may be new answers.
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
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> 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
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Freeze the GUI on a button click process.
 
Similar Threads
h:messages problem
how to undo the last action printed on an applet using undo button
Problem in jsp..
regarding JTextField
how to undo the last action printed on an applet using undo button