Advertisement
Guest User

Untitled

a guest
Aug 26th, 2013
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. public class XXX
  2. {
  3. public static void main(String args[]) {
  4. JComponent comp = new JTable(); // some panel or table
  5. comp.getInputMap().put(KeyStroke.getKeyStroke("F4"), "xxxaction");
  6. comp..getActionMap().put("xxxaction", new XXXAction());
  7. }
  8.  
  9. public class XXXAction extends AbstractAction
  10. {
  11. @Override
  12. public void actionPerformed(ActionEvent e)
  13. {
  14. // Something;
  15. }
  16. }
  17. }
  18.  
  19. Action action = component.getActionMap().get("...");
  20.  
  21. if (action != null)
  22. {
  23. ActionEvent ae = new ActionEvent(component, ActionEvent.ACTION_PERFORMED, "");
  24. action.actionPerformed( ae );
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement