This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes EnterKey to switch panels Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "EnterKey to switch panels" Watch "EnterKey to switch panels" New topic
Author

EnterKey to switch panels

Joe Groves
Greenhorn

Joined: Dec 14, 2011
Posts: 1
hey i have a tiny problem...

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
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: 4340
    
    2

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
Visit my download page
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> 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: 4340
    
    2

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EnterKey to switch panels
 
Similar Threads
Should I switch by ints or chars?
Problrm in calling userdefined method in onclick event of button dynamically
Assertions
I Don't believe it
switch doubt..