1

How can you reassign a windows action to a key combination in Java? I want to basically share the default windows 'Page Down' action to a key combination such as 'control D'.

This is what I have so far:

KeyStroke addedKeyStroke = KeyStroke.getKeyStroke("control D");
getInputMap().put(addedKeyStroke, "page-down");

However, nothing happens when I press ctrl-L. Please could someone let me know what needs to be done to get this working?

Thanks,

maloney
  • 1,633
  • 3
  • 26
  • 49

1 Answers1

1

EDIT

KeyStroke addedKeyStroke = KeyStroke.getKeyStroke("control D");
InputMap inputMap = myTable.getInputMap(JComponent.WHEN_FOCUSED);
inputMap.put(addedKeyStroke , "scrollDownChangeSelection"); 

Also see this answer

Community
  • 1
  • 1
nachokk
  • 14,363
  • 4
  • 24
  • 53
  • Im afraid none of those options seem to work. I'm trying in a JTable – maloney Feb 26 '14 at 13:20
  • I have just managed to fix this. Used 'WHEN_FOCUSED' and changed the 3rd line to: inputMap.put(addedKeyStroke, "scrollDownChangeSelection"); – maloney Feb 26 '14 at 13:29
  • @maloney great! you got it i provide a link with a trashgod answer! you should provide your own answer i'll upvote you! – nachokk Feb 26 '14 at 13:34