Java Swing ActionMap putAction(JComponent component, Action action)

Here you can find the source of putAction(JComponent component, Action action)

Description

put Action

License

Open Source License

Declaration

public static void putAction(JComponent component, Action action) 

Method Source Code

//package com.java2s;
/**/*from w  w w .  j av  a  2s .  c o  m*/
 * This file is part of MadCommander, a file manager with two panels.
 *
 * MadCommander is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MadCommander is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MadCommander.  If not, see <http://www.gnu.org/licenses/>.
 */

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

public class Main {
    public static void putAction(JComponent component, Action action) {
        KeyStroke keyStroke = (KeyStroke) action.getValue(Action.ACCELERATOR_KEY);
        String name = (String) action.getValue(Action.NAME);

        component.getInputMap().put(keyStroke, name);
        component.getActionMap().put(name, action);
    }
}

Related

  1. fillInputMap(ActionMap am)
  2. installActions(JComponent comp, Action actions[], int condition)
  3. printActionInputMap(JComponent comp)
  4. printActionMap(ActionMap actionMap, String who)
  5. putAction(Action action)
  6. registerAction(JComponent component, int condition, Action action, String command)
  7. registerUndoRedoActions(JComponent jtc, Action undoAction, Action redoAction)
  8. removeAction(InputMap im, ActionMap am, String name)
  9. sysoutActionMap(JComponent com)