Java Swing KeyStroke mapInput(JComponent component, int scope, final int keycode, final int modifiers, final AbstractAction action)

Here you can find the source of mapInput(JComponent component, int scope, final int keycode, final int modifiers, final AbstractAction action)

Description

map Input

License

LGPL

Declaration

public static void mapInput(JComponent component, int scope, final int keycode, final int modifiers,
            final AbstractAction action) 

Method Source Code


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

import javax.swing.*;

public class Main {
    public static void mapInput(JComponent component, int scope, final int keycode, final int modifiers,
            final AbstractAction action) {
        if (component instanceof JComponent) {
            JComponent jc = (JComponent) component;
            String hash = String.valueOf(System.identityHashCode(action));
            jc.getInputMap(scope).put(KeyStroke.getKeyStroke(keycode, modifiers), hash);
            jc.getActionMap().put(hash, action);
        }/*  www  .  j  a  v  a 2s  . co  m*/
    }
}

Related

  1. installKey(final JComponent comp, final String keyString, final int key, final Action action)
  2. installKeyBinding(JComponent c, int condition, String actionName, Action action, KeyStroke... keyStrokes)
  3. installKeyBindings()
  4. installKeystrokes(JComponent component, Action... actions)
  5. isKeyStroke(String propClass)
  6. mapKeyStrokeAction(JComponent component, String actionMapKey, Action action, KeyStroke keyStroke)
  7. mapKeyStrokeToAction(final JComponent comp, final String ks, final String name, final AbstractAction action)
  8. mapKeyStrokeToButton(final JComponent comp, final String ks, final String name, final AbstractButton button)
  9. maybeInstall(InputMap map, String action, KeyStroke stroke)