Java Swing KeyStroke addKeyBinding(JComponent comp, KeyStroke key, String id, Action action)

Here you can find the source of addKeyBinding(JComponent comp, KeyStroke key, String id, Action action)

Description

add Key Binding

License

Apache License

Declaration

public static void addKeyBinding(JComponent comp, KeyStroke key, String id, Action action) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.swing.Action;

import javax.swing.JComponent;
import javax.swing.KeyStroke;

public class Main {
    public static void addKeyBinding(JComponent comp, KeyStroke key, String id, Action action) {
        comp.getInputMap().put(key, id);
        comp.getActionMap().put(id, action);
    }//from   w  ww.  j  a v a 2 s .  c o m
}

Related

  1. addButtonClickKeystroke(final AbstractButton b, KeyStroke ks, Object key)
  2. addFocusBackKey(final int button)
  3. addFocusTraversalKey(final JComponent target, final int keyCode, final int modifiers, final int id)
  4. addHotKey(JComponent pane, Action action, KeyStroke key)
  5. addHotKey(JComponent pane, Action action, KeyStroke key)
  6. addKeyboardAction(Action action, KeyStroke keyStroke, JComponent component)
  7. addKeyboardShortcut(final JComponent target, final AbstractButton button, final KeyStroke keyStroke)
  8. addShortcut(JRootPane rootPane, String command, Action action, KeyStroke stroke)
  9. addShortcutAction(String name, JComponent component, KeyStroke key, Action action)