[java] Key listeners in Applets
I''m trying to add a key listener to my applet.
I have this code inside of init():
addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent e)
{
System.out.println("Key pressed.");
}
});
This should work. It works fine in an application. I can
get mouse listeners to work using this same technique.
I think the problem is that the applet doesn''t have the
"focus" of the keyboard (e.g. when I use appletviewer to run
it the keyboard controls the buttons at the top of the appletviewer.)
Is there anyway to get around this problem?
Thanks
January 31, 2001 10:24 AM
call requestFocus() either in the init method of your applet, or
when a mouse click occurs.
when a mouse click occurs.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement