This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hi all, I have a dialog that will create a second dialog. When I hit the ESC key, I want to close the visible window. If only the parent is visible, I want to close the parent. If the child is visible, I only want to close the child. Right now, I'm closing both. I'm just doing this: protected void processKeyEvent(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { hide(); } else { super.processKeyEvent(e); } } any suggestions?
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
Presuming the child is modal, something like this:
"JavaRanch, where the deer and the Certified play" - David O'Meara
Pres Brawner
Ranch Hand
Joined: Jan 18, 2001
Posts: 92
posted
0
A couple of questions: What if it is not modal? How do I know for sure? How do I determine the identify of "child"?
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
If the child is modal, it will always be in front of the parent, and MUST be dealt with before doing anything to the parent. Actually the code that I gave you works in either case, however it will close the child dialog first, EVEN IF the parent dialog is currently in focus (in front of the child). When you create the dialog you control the modal property either using the appropriate constructor or the setModal() method. By default it is non-modal, so if YOU didn't set it to modal then it's not. Give the dialogs names: Dialog parent = new Dialog(); Dialog child = new Dialog();
Pres Brawner
Ranch Hand
Joined: Jan 18, 2001
Posts: 92
posted
0
OK. My child window is not modal. The code you gave me does not work for me because I cannot identify "child". I know I'm doing something wrong. I'm not thinking about this the way the designers of Swing intended. An "Ah Hah!" experience is near at hand. Could you give me another boost? I'm just not getting this yet. Thanks, Pres
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
Show us what you have, and perhaps we can get an idea.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.