I'm trying to add a key listener to a component that explicity doesn't listen, I mean, I'm using a JPanel as a drawing area, well as a matter of fact, I want to hear the key events, I have tried the following cases,
public class Pizarron extends JPanel { JPanel areaDib; Pizarron() { areaDib = new JPanel(); areaDib.addKeyListener(new MyKeyListener()); }
private class MyKeyListener extends KeyAdapter { public void keyPressed (KeyEvent e) { System.out.println(e.getKeyText (e.getKeyCode())); }
public void keyReleased (KeyEvent e) { System.out.println(e.getKeyText(e.getKeyCode())); }
public void keyTyped (KeyEvent e) { System.out.println(e.getKeyChar()); } }
}
I've been doing the same listeners inner classes with Mouse Listener, and it works!, really it works in a very easy way, but,
what happened with non-key listener components?, is there some other special stuff that I have to do?