KeyListener losing its way

J

JavaEnquirer

If I add a KeyListener to a frame, capturing key presses and drawing
corresponding lines on a JPanel, everything works fine - I can doodle
to my hearts content. ( The panel has been added to the center of the
frame's borderlayout.)

However, the moment I add a Swing control such as a JButton to another
panel e.g. on the West, my frame level key listener no longer seems to
work even when I attempt to give the frame focus.

Any ideas??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top