A
Allan Valeriano
Hi,
I have this class that extends JFrame, and I'd like to close it when
the user presses the ESC key.
I've tryed the code:
addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == 27){
System.out.println("closing...");
close();
}
}
public void keyTyped(KeyEvent e) {
}
});
but it seems useless, since there's no output when the ESC key is
pressed.
Anybody knows how to do that?
thanks in advance
Allan Valeriano
I have this class that extends JFrame, and I'd like to close it when
the user presses the ESC key.
I've tryed the code:
addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == 27){
System.out.println("closing...");
close();
}
}
public void keyTyped(KeyEvent e) {
}
});
but it seems useless, since there's no output when the ESC key is
pressed.
Anybody knows how to do that?
thanks in advance
Allan Valeriano