Example usage for javax.swing Action ACTION_COMMAND_KEY

List of usage examples for javax.swing Action ACTION_COMMAND_KEY

Introduction

In this page you can find the example usage for javax.swing Action ACTION_COMMAND_KEY.

Prototype

String ACTION_COMMAND_KEY

To view the source code for javax.swing Action ACTION_COMMAND_KEY.

Click Source Link

Document

The key used to determine the command String for the ActionEvent that will be created when an Action is going to be notified as the result of residing in a Keymap associated with a JComponent.

Usage

From source file:Main.java

/**
 * Binds an action to a component. Uses the <code>Action.ACTION_COMMAND_KEY</code> and <code>Action.ACCELERATOR_KEY</code> action
 * properties.//from   w w  w  . j  a v  a  2  s . c o  m
 * 
 * @param component
 *            the component.
 * @param action
 *            the action to bind.
 */
public static void bindAction(JComponent component, Action action) {
    component.getInputMap().put((KeyStroke) action.getValue(Action.ACCELERATOR_KEY),
            action.getValue(Action.ACTION_COMMAND_KEY));
    component.getActionMap().put(action.getValue(Action.ACTION_COMMAND_KEY), action);
}

From source file:Main.java

/**
 * Make sure that {@link #getActionID(Action)} returns the passed string.
 * /* w  ww.j a  v a  2  s . c  o  m*/
 * @param a an action.
 * @param id a string to be stored in {@link Action#ACTION_COMMAND_KEY}.
 */
public static final void setActionID(final Action a, final String id) {
    a.putValue(Action.ACTION_COMMAND_KEY, id);
}

From source file:Main.java

public static boolean invoke(Action action, Object source) {
    if (action == null || !action.isEnabled()) {
        return false;
    }//from  ww w.  ja  v a2  s  .c  o  m
    ActionEvent evt = new ActionEvent(source, ActionEvent.ACTION_PERFORMED,
            (String) action.getValue(Action.ACTION_COMMAND_KEY), 0);
    action.actionPerformed(evt);
    return true;
}

From source file:Main.java

/**
 * Programmatically perform action on textfield.This does the same
 * thing as if the user had pressed enter key in textfield.
 *
 * @param textField textField on which action to be preformed
 */// w  w w.  ja  v a  2  s .c o m
public static void doAction(JTextField textField) {
    String command = null;
    if (textField.getAction() != null)
        command = (String) textField.getAction().getValue(Action.ACTION_COMMAND_KEY);
    ActionEvent event = null;

    for (ActionListener listener : textField.getActionListeners()) {
        if (event == null)
            event = new ActionEvent(textField, ActionEvent.ACTION_PERFORMED, command,
                    System.currentTimeMillis(), 0);
        listener.actionPerformed(event);
    }
}

From source file:Main.java

public ShowAction() {
    super("About");

    putValue(Action.ACTION_COMMAND_KEY, "command");
    putValue(Action.NAME, "Go to number ");

}

From source file:lince.controladores.exportar.AbrirExportarHoisan.java

public AbrirExportarHoisan() {
    putValue(Action.NAME, ResourceBundleHelper.getI18NLabel("HOISAN"));
    putValue(Action.ACTION_COMMAND_KEY, EXPORT_HOISAN_COMMAND_ID);
    putValue(Action.SHORT_DESCRIPTION, ResourceBundleHelper.getI18NLabel("actions.export.Hoisan"));
}

From source file:com.sshtools.common.ui.NewWindowAction.java

/**
 * Creates a new NewWindowAction object.
 *
 * @param application/*  w w  w. j  a  va  2 s. c om*/
 */
public NewWindowAction(SshToolsApplication application) {
    this.application = application;

    putValue(Action.NAME, "New Window");
    putValue(Action.SMALL_ICON, getIcon("/com/sshtools/common/ui/newwindow.png"));
    putValue(LARGE_ICON, getIcon("/com/sshtools/common/ui/largenewwindow.png"));
    putValue(Action.SHORT_DESCRIPTION, "Create new window");
    putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_W, KeyEvent.ALT_MASK));
    putValue(Action.LONG_DESCRIPTION, "Create a new SSHTerm window");
    putValue(Action.MNEMONIC_KEY, new Integer('w'));
    putValue(Action.ACTION_COMMAND_KEY, "new-window");
    putValue(StandardAction.ON_MENUBAR, new Boolean(true));
    putValue(StandardAction.MENU_NAME, "File");
    putValue(StandardAction.MENU_ITEM_GROUP, new Integer(0));
    putValue(StandardAction.MENU_ITEM_WEIGHT, new Integer(90));
    putValue(StandardAction.ON_TOOLBAR, new Boolean(true));
    putValue(StandardAction.TOOLBAR_GROUP, new Integer(0));
    putValue(StandardAction.TOOLBAR_WEIGHT, new Integer(90));
}

From source file:net.pandoragames.far.ui.swing.component.listener.CommandRename.java

public CommandRename(UIFace uiBean, Localizer localizer, JFrame root) {
    super(uiBean);
    properties.put(Action.ACTION_COMMAND_KEY, OperationType.RENAME.name());
    properties.put(Action.NAME, localizer.localize("button.rename"));
    this.localizer = localizer;
    rootWindow = root;/*from   w  ww  . ja  v  a  2 s .  c  o m*/
}

From source file:com.sshtools.sshterm.FullScreenAction.java

public FullScreenAction(SshToolsApplication application, SshToolsApplicationContainer container) {
    this.application = application;
    this.container = container;
    putValue(Action.NAME, NAME_FULL_SCREEN);
    putValue(Action.SMALL_ICON, getIcon(SMALL_ICON_FULL_SCREEN));
    putValue(LARGE_ICON, getIcon(LARGE_ICON_FULL_SCREEN));
    putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F, KeyEvent.ALT_MASK));
    putValue(Action.SHORT_DESCRIPTION, SHORT_DESCRIPTION_FULL_SCREEN);
    putValue(Action.LONG_DESCRIPTION, LONG_DESCRIPTION_FULL_SCREEN);
    putValue(Action.MNEMONIC_KEY, new Integer(MNEMONIC_KEY_FULL_SCREEN));
    putValue(Action.ACTION_COMMAND_KEY, ACTION_COMMAND_KEY_FULL_SCREEN);
    putValue(StandardAction.ON_MENUBAR, new Boolean(true));
    putValue(StandardAction.MENU_NAME, "View");
    putValue(StandardAction.MENU_ITEM_GROUP, new Integer(20));
    putValue(StandardAction.MENU_ITEM_WEIGHT, new Integer(20));
    putValue(StandardAction.ON_TOOLBAR, new Boolean(true));
    putValue(StandardAction.TOOLBAR_GROUP, new Integer(5));
    putValue(StandardAction.TOOLBAR_WEIGHT, new Integer(30));
}

From source file:com.sshtools.powervnc.VncFullScreenAction.java

public VncFullScreenAction(SshToolsApplication application, SshToolsApplicationContainer container) {
    this.application = application;
    this.container = container;
    putValue(Action.NAME, NAME_FULL_SCREEN);
    putValue(Action.SMALL_ICON, getIcon(SMALL_ICON_FULL_SCREEN));
    putValue(LARGE_ICON, getIcon(LARGE_ICON_FULL_SCREEN));
    putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F, KeyEvent.ALT_MASK));
    putValue(Action.SHORT_DESCRIPTION, SHORT_DESCRIPTION_FULL_SCREEN);
    putValue(Action.LONG_DESCRIPTION, LONG_DESCRIPTION_FULL_SCREEN);
    putValue(Action.MNEMONIC_KEY, new Integer(MNEMONIC_KEY_FULL_SCREEN));
    putValue(Action.ACTION_COMMAND_KEY, ACTION_COMMAND_KEY_FULL_SCREEN);
    putValue(StandardAction.ON_MENUBAR, new Boolean(true));
    putValue(StandardAction.MENU_NAME, "View");
    putValue(StandardAction.MENU_ITEM_GROUP, new Integer(20));
    putValue(StandardAction.MENU_ITEM_WEIGHT, new Integer(20));
    putValue(StandardAction.ON_TOOLBAR, new Boolean(true));
    putValue(StandardAction.TOOLBAR_GROUP, new Integer(5));
    putValue(StandardAction.TOOLBAR_WEIGHT, new Integer(30));
}