public class KL implements KeyListener {
public static void main(String[] args) {
final JPopupMenu popup = new JPopupMenu();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 200);
frame.setVisible(true);
}
@Override
public void keyPressed(KeyEvent arg0) {
System.out.println(arg0.getKeyChar());
}
@Override
public void keyReleased(KeyEvent e) {
System.out.println(e.getKeyChar());
}
@Override
public void keyTyped(KeyEvent e) {
System.out.println(e.getKeyChar());
}
}
That's my class, it's probably something really stupid on my part, but my KeyListener here is not working. Nothing comes up on the console.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…