• Post Reply Bookmark Topic Watch Topic
  • New Topic

Short cut keys  RSS feed

 
kalai sundar
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My problem is , i have TabbedPane in that have 3 panel, i want to select those pane with keys, no through mouse, how to do that,

vat i have done is


if(evt.getKeyCode()==evt.VK_1){
jPanel2.setFocusable(true);

}
if(evt.getKeyCode()==evt.VK_2){
jPanel3.setFocusable(true);
}
if(evt.getKeyCode()==evt.VK_3){
jPanel4.setFocusable(true);
}

this is not working, how to do that plz hepl me


kalai
 
Frank Ertl
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kalai,

try to use myTabbedPane.setSelectedIndex(<x> ) where <x> is the index of the tab in the TabbedPane. setFousable(true) will only make it possible for the component (in your case jPanel1 to jPanel4) to receive the Focus which is true by default.
You can also use myTabbedPane.setSelectedComponent(jPanel1).

Frank
[ October 07, 2005: Message edited by: Frank Ertl ]
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the tab key to navigate through your gui. You can also bind KeyStrokes to your JTabbedPane, see How to Use KeyBindings. Or you can customize the focus cycle with a FocusTraversalPolicy, see How to Use the Focus Subsystem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!