Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

shortcut key action (ctrl+arrow) in button  RSS feed

 
pratap chandran
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one screen that contains JTable, JCheckbox and JButton. I need to perform shortcut key action on one JButton to perform the action to move the content from one JTable to another JTable. The shortcut key to perform this operation on this JButton is ctrl+right arrow. I am using registerKeyBoardAction(). My code is:

this.selectAllBtn.registerKeyboardAction(this.actionListener,
KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,
InputEvent.CTRL_DOWN_MASK),
JComponent.WHEN_IN_FOCUSED_WINDOW);

When the focus is in the main window this code is working. But when the focus is in the JTable this code not working.

Similarly "PAGE_UP" & "PAGE_DOWN" key also not working without the modifier keys irrespective of the focus. The code for this is :

this.moveUpAllBtn.registerKeyboardAction(this.actionListener,
KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0),
JComponent.WHEN_IN_FOCUSED_WINDOW);

Can anyone help me to perform these action?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!