[BLUEJ-453] JFrame with KeyListener not reacting on Key-Events after restart of BlueJ
When you create a JFrame with a KeyListener and compile&start the application, everything works fine. But if you close & restart BlueJ and run the application again, the application doesn't react on key-events (although your application has the focus). In this case you have to focus another window and switch back to your application to enable the reaction on key-events.
Here is a code-snippet to reproduce the behaviour:
{noformat} #!java import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JLabel; import javax.swing.JTextArea; import java.awt.event.KeyListener; import java.awt.event.KeyEvent; import java.awt.event.KeyAdapter;
public class Test extends KeyAdapter { public static void main(String[] args){ JFrame frame = new JFrame(); JPanel panel = new JPanel(); frame.add(panel); frame.addKeyListener(new Test()); frame.setSize(800,600); frame.setVisible(true); }
@Override
public void keyPressed(KeyEvent e){
System.out.println(e.getKeyChar());
}
} {noformat}
Issue metadata
- Issue type: Bug
- Priority: Medium