KeyListener

B

Bumsys

How add KeyListener to JFrame?
Simply I want that when I press F5 the content of JFrame refresh.
 
B

Bumsys

I add JPanel to JFrame with setContentPane(panel) and KeyListener does
not work. If I do not write setContentPane(panel) then KeyListener
work normally. What is the reason?
 
A

Andrew Thompson

I add JPanel to JFrame with setContentPane(panel) and KeyListener does
not work. If I do not write setContentPane(panel) then KeyListener
work normally. What is the reason?

System.out.println( panel.isFocusable() );
System.out.println( panel.hasFocus() );

If that print out does not fix the problem for you,
you might try posting an SSCCE* of failing code.

* <http://pscode.org/sscce.html>
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top