2008-06-23

Add KeyListener On Swing JPanel

Use code like this

JFrame frame = new JFrame();
JPanel pnl = new JPanel();
pnl.addKeyListener(keyListener);
pnl.setFocusable(true);
frame.add(pnl);
frame.pack();
pnl.drawing.requestFocus();

No comments: