Java Swing ActionMap installActions(JComponent comp, Action actions[], int condition)

Here you can find the source of installActions(JComponent comp, Action actions[], int condition)

Description

install Actions

License

Open Source License

Declaration

public static void installActions(JComponent comp, Action actions[], int condition) 

Method Source Code

//package com.java2s;
/**/*from  ww w .j  a  va  2s . co m*/
 * MySwing: Advanced Swing Utilites
 * Copyright (C) 2005  Santhosh Kumar T
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 */

import javax.swing.*;

public class Main {
    public static void installActions(JComponent comp, Action actions[], int condition) {
        ActionMap actionMap = comp.getActionMap();
        InputMap inputMap = comp.getInputMap(condition);
        for (int i = 0; i < actions.length; i++) {
            String name = (String) actions[i].getValue(Action.NAME);
            actionMap.put(name, actions[i]);
            inputMap.put((KeyStroke) actions[i].getValue(Action.ACCELERATOR_KEY), name);
        }
    }

    public static void installActions(JComponent comp, Action actions[]) {
        installActions(comp, actions, JComponent.WHEN_FOCUSED);
    }
}

Related

  1. bindAction(JComponent aComponent, String aCommand, Action anAction)
  2. checkActions(JComponent aComponent)
  3. cloneActionMap(ActionMap original)
  4. dumpActionMap(JComponent comp)
  5. fillInputMap(ActionMap am)
  6. printActionInputMap(JComponent comp)
  7. printActionMap(ActionMap actionMap, String who)
  8. putAction(Action action)
  9. putAction(JComponent component, Action action)