|
-
August 11th, 2009, 08:10 PM
#1
frame.toFront(), but not all the way?
i want primary frame A to come to focus when the user clicks on it, but i also want secondary frame B to come up just behind it.
from within frame A, I write:
public void windowGainedFocus(WindowEvent e) {
if(windowB.getState() == Frame.ICONIFIED) windowB.setState(Frame.NORMAL);
windowB.toFront();
}
but i dont want window B in focus, i just want it visible. how can i do this?
thanks
-
August 12th, 2009, 06:32 AM
#2
Re: frame.toFront(), but not all the way?
Have you tried following the call to windowB.toFront() with a call to this.toFront(), so windowB comes to the front then the current window comes in front of it? You may have to make the second call in a SwingUtilities.invokeLater() block to ensure that windowB has come to the front before you bring the current window to the front.
Vague and nebulous is the beginning of all things, but not their end...
K. Gibran
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
August 12th, 2009, 03:01 PM
#3
Re: frame.toFront(), but not all the way?
yes I have, but once that is initiated, it will repetitively call this method and the windows will just flicker in a never-ending sequence
-
August 12th, 2009, 05:57 PM
#4
Re: frame.toFront(), but not all the way?
Yes... I see the problem. You could get around it by setting a boolean member variable true when you call this.toFront(), and checking it at the start of the windowGainedFocus method - if it's true, the method has just been called, so you don't need to do anything but set the boolean back to false. If it's false, then continue with the method, setting B to front, then A to front and set the boolean true to stop the repeating. Something like this:
Code:
boolean atFront = false;
...
public void windowGainedFocus(WindowEvent e) {
if (atFront) {
atFront = false;
return;
}
if(windowB.getState() == Frame.ICONIFIED) {
windowB.setState(Frame.NORMAL);
}
windowB.toFront();
atFront = true;
this.toFront();
}
It's a bit clunky, but should work. I can't think of a better way off the top of my head...
The person who says it cannot be done should not interrupt the person doing it...
Chinese proverb
Last edited by dlorde; August 12th, 2009 at 06:01 PM.
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|