i need to have my program react to the enter key to switch from one panel to another
any one know how i can do this?
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
3
KeyBindings
or, if you already have a button thast does the job, set the button as the default button
Randall Twede
Ranch Hand
Joined: Oct 21, 2000
Posts: 4089
posted
0
from what i can see it looks the same as handling other events. import KeyEvent and KeyListener. implement Keylistener or use a seperate listener class. write the 3 methods of KeyListener.
void keyPressed(KeyEvent e)
Invoked when a key has been pressed.
void keyReleased(KeyEvent e)
Invoked when a key has been released.
void keyTyped(KeyEvent e)
Invoked when a key has been typed.
tip: some methods can be do nothing methods.
SCJP
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
1
> import KeyEvent and KeyListener. implement Keylistener or use a seperate listener class
let's say there's 10 focusable components displayed.
are you going to add keyListeners to each?
Randall Twede
Ranch Hand
Joined: Oct 21, 2000
Posts: 4089
posted
0
actually i havent listened to keys much. only a few homeworks that did this:
programMenu.setMnemonic( KeyEvent.VK_P );
and the professor actually wrote that part for us.
is that what keybinding is?
well i can google it KeyBindings