Hello everyone,
In Java, I am adding a KeyListener to a JWindow, but it is not getting any key events. If I used the same code but extend a JFrame instead, then everything works fine.
public class MyWindow extends JWindow {
...
...
private void initComponents() {
...
...
addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
System.out.println("KEY PRESSED: " + e.getKeyCode());
}
public void keyReleased(KeyEvent e) {
System.out.println("KEY RELEASED: " + e.getKeyCode());
}
public void keyTyped(KeyEvent e) {
System.out.println("KEY TYPED: " + e.getKeyCode());
}
});
}
}
Anyone know how can I solve this by using a JWindow?
Please note that I am using Linux, so I am not sure if it is something to do with the platform.
Thanks