Max said:
myWindowOwner = new JFrame();
myWindow = new JWindow(myWindowOwner);
then later on
myWindowOwner.addKeyListener(this);
myWindow.addKeyListener(this);
None of those are able to detect key input. Mouse input works just fine
with mouse listener.
Okay, back to the second part of my response, then. Both JFrame and
JWindow contain a JRootPane, which contains such things as a content
pane, a glass pane, etc. If one of those child components has focus
instead of the top-level window, then the KeyEvent will be lost.
Instead, use getInputMap and getActionMap to associate your action with
a KeyStroke, and specify a more generic condition to getInputMap.
The API docs for getInputMap and getActionMap are in JComponent.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation