Hey all,
I am trying to implement a KeyListener into my JFrame. I have used the following code (at the moment im just trying to get this to work with my JFrame).
System.out.println("test");
addKeyListener(new KeyListener()
{
public void keyPressed(KeyEvent e) { System.out.println( "tester"); }
public void keyReleased(KeyEvent e) { System.out.println("2test2"); }
public void keyTyped(KeyEvent e) { System.out.println("3test3"); }
});
This is currently located in my default constructor. The "test" comes up in my console, however, when I press a button, I am not getting any other messages, as if the key listener was not even there. I was thinking possibly that it is because the focus is not on the JFrame and so they KeyListener is not working, but i'm pretty sure it is
Is there something that I am missing?
Thanks again in advance,
Tomek