Results 1 to 9 of 9
- 07-07-2011, 03:30 AM #1
Member
- Join Date
- Jul 2011
- Posts
- 12
- Rep Power
- 0
disabling and re-enabling a jframe
I have a root window with two buttons on it. When one of those buttons is pressed I want the root window to be disabled while a new window pops up. After I'm finished with that window I want the root window to be re-enabled. Here is how I'm trying to do it.
This doesn't disable the root window at all. If i comment out the setEnabled line it will disable the root window, but I can't interact with it once I'm done with the second window.Java Code:addBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { frame.setEnabled(false); addKid(); frame.setEnabled(true); } });
- 07-07-2011, 03:43 AM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
This button simply sets enabled, does something else and then sets enabled back.
So if it's enabled initially it will disable and re enable it in a very short amount of time(nanoseconds most likely), you should probably have a button to disable it and one to enable it, or use a timer to put a pause in.
- 07-07-2011, 03:57 AM #3
What does the addKid() method do?After I'm finished with that window
Your call to addKid() is on Swing's EDT thread. That could effect how Swing responds since you are using its thread.
- 07-07-2011, 04:00 AM #4
Member
- Join Date
- Jul 2011
- Posts
- 12
- Rep Power
- 0
Yes, the function addKid() opens another JFrame. I figured that frame.setEnabled(true) wouldn't be called until I was done with the addKid() function. How would I go about putting a pause in?This button simply sets enabled, does something else and then sets enabled back.
- 07-07-2011, 04:01 AM #5
That sounds like you need a modal dialog. It will pause the execution of the calling code until the dialog returns.
- 07-07-2011, 04:17 AM #6
Member
- Join Date
- Jul 2011
- Posts
- 12
- Rep Power
- 0
Any way I could do it without dialogs? My addkid() function brings up a new JFrame with a bunch of JTextFields that are used to enter information. Is it possible to use JTextFields in a dialog?
- 07-07-2011, 04:20 AM #7
I think you can put about any component into a JDialog. There is a link from the JDialog API doc to a tutorial on How to Make Dialogs.
-
- 07-07-2011, 05:20 AM #9
Member
- Join Date
- Jul 2011
- Posts
- 12
- Rep Power
- 0
Similar Threads
-
Enabling Javascript
By drewsonoffergus in forum NetworkingReplies: 1Last Post: 08-06-2011, 08:42 PM -
enabling keystrokes
By elieN in forum AWT / SwingReplies: 7Last Post: 05-28-2011, 06:29 PM -
disabling JFrame's response to spacebar
By gib65 in forum AWT / SwingReplies: 2Last Post: 11-01-2010, 04:38 PM -
repeated enabling disabling icon (card flipping)
By luckylandie in forum AWT / SwingReplies: 3Last Post: 07-23-2010, 11:01 PM -
Enabling/disabling menu depending on clipboard content availability
By Java Tip in forum SWTReplies: 0Last Post: 07-07-2008, 04:35 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks