Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #840
| From | "John T. Dow" <john.t..dow@THRWHITE.remove-dii-this> |
|---|---|
| Subject | JDialog not consuming ESC |
| Message-ID | <Xns98C9F5DBEC79johnjohntdowcom@207.217.125.201> (permalink) |
| Newsgroups | comp.lang.java.gui |
| Date | 2011-04-27 15:29 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui
I have a JDialog that responds to an ESC key regardless of which component
has the focus. This is what I want.
However, it seems that the esc key is not consumed, because upon disposing
of this dialog, when I open another, it immediately acts as if ESC has been
pressed.
I assume that the ESC key is not being consumed. Here's what I'm doing.
Blank lines inserted for clarity. Here I show using WHEN_FOCUSED,
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, and WHEN_IN_FOCUSED_WINDOW all at once,
but I've of course tried them individually. I think
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT is the appropriate one to use, but that
didn't seem to be firing. It's late at night and I just did all three for
the heck of it. One of them is working and the EscKeyPressed method is
being called. That much works.
KeyStroke esc = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
DialogMainPanel.getInputMap(JComponent.WHEN_FOCUSED).put(esc, "ESCAPE");
DialogMainPanel.getInputMap
(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(esc, "ESCAPE");
DialogMainPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(esc,
"ESCAPE");
DialogMainPanel.getActionMap().put("ESCAPE", new EscKeyPressed());
John
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Next in thread | Find similar
JDialog not consuming ESC "John T. Dow" <john.t..dow@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
Re: JDialog not consuming "Edwin Dankert" <edwin.dankert@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
Re: JDialog not consuming "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
Re: JDialog not consuming "John T. Dow" <john.t..dow@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
Re: JDialog not consuming "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
Re: JDialog not consuming "Brandon McCombs" <brandon.mccombs@THRWHITE.remove-dii-this> - 2011-04-27 15:30 +0000
Re: JDialog not consuming "chipu" <chipu@THRWHITE.remove-dii-this> - 2011-04-27 15:29 +0000
Re: JDialog not consuming "John T. Dow" <john.t..dow@THRWHITE.remove-dii-this> - 2011-04-27 15:30 +0000
Re: JDialog not consuming "chipu" <chipu@THRWHITE.remove-dii-this> - 2011-04-27 15:30 +0000
Re: JDialog not consuming "John T. Dow" <john.t..dow@THRWHITE.remove-dii-this> - 2011-04-27 15:30 +0000
csiph-web