Example usage for javax.swing Action ACCELERATOR_KEY

List of usage examples for javax.swing Action ACCELERATOR_KEY

Introduction

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

Prototype

String ACCELERATOR_KEY

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

Click Source Link

Document

The key used for storing a KeyStroke to be used as the accelerator for the action.

Usage

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

/**
 * Creates a new NewWindowAction object.
 *
 * @param application//from   w  w w .j a v a  2 s  . c  o  m
 */
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:Main.java

public ExitAction(String name) {
    super(name);//from w  w  w .  j av a 2s  .  c  o m
    this.putValue(Action.MNEMONIC_KEY, exitKey.getKeyCode());
    this.putValue(Action.ACCELERATOR_KEY, exitKey);
}

From source file:com.stefanbrenner.droplet.ui.actions.SaveFileAction.java

public SaveFileAction(final JFrame frame, final JFileChooser fileChooser,
        final IDropletContext dropletContext) {
    this(Messages.getString("SaveFileAction.title"), frame, fileChooser, dropletContext); //$NON-NLS-1$

    putValue(Action.ACCELERATOR_KEY, UiUtils.getAccelerator(KeyEvent.VK_S));
    putValue(Action.MNEMONIC_KEY, UiUtils.getMnemonic(Messages.getString("SaveFileAction.mnemonic"))); //$NON-NLS-1$
    putValue(Action.SHORT_DESCRIPTION, Messages.getString("SaveFileAction.description")); //$NON-NLS-1$
}

From source file:ca.sfu.federation.action.CreateProjectAction.java

/**
 * CreateProjectAction default constructor.
 *//*from www .j  a  v a 2 s  .  c o  m*/
public CreateProjectAction() {
    super("New Project", null);
    Icon icon = ImageIconUtils.loadIconById("file-new-project-icon");
    this.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control shift N"));
    this.putValue(Action.LONG_DESCRIPTION, "Create a new project");
    this.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_N);
    this.putValue(Action.SHORT_DESCRIPTION, "Create a new project");
    this.putValue(Action.SMALL_ICON, icon);
}

From source file:com.stefanbrenner.droplet.ui.actions.OpenFileAction.java

protected OpenFileAction(final JFrame frame, final JFileChooser fileChooser,
        final IDropletContext dropletContext, final String title) {
    super(frame, dropletContext, title);

    this.fileChooser = fileChooser;

    putValue(Action.ACCELERATOR_KEY, UiUtils.getAccelerator(KeyEvent.VK_O));
    putValue(Action.MNEMONIC_KEY, UiUtils.getMnemonic(Messages.getString("OpenFileAction.mnemonic"))); //$NON-NLS-1$
    putValue(Action.SHORT_DESCRIPTION, Messages.getString("OpenFileAction.description")); //$NON-NLS-1$
}

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));
}

From source file:net.sf.jabref.importer.ImportFormats.java

/**
 * Create an AbstractAction for performing an Import operation.
 * @param frame The JabRefFrame of this JabRef instance.
 * @param openInNew Indicate whether the action should open into a new database or
 *  into the currently open one.//from  ww w . ja  v a 2 s. c o m
 * @return The action.
 */
public static AbstractAction getImportAction(JabRefFrame frame, boolean openInNew) {

    class ImportAction extends MnemonicAwareAction {

        private final JabRefFrame frame;
        private final boolean openInNew;

        public ImportAction(JabRefFrame frame, boolean openInNew) {
            this.frame = frame;
            this.openInNew = openInNew;

            putValue(Action.NAME, openInNew ? Localization.menuTitle("Import into new database")
                    : Localization.menuTitle("Import into current database"));
            putValue(Action.ACCELERATOR_KEY,
                    openInNew ? Globals.getKeyPrefs().getKey(KeyBinding.IMPORT_INTO_NEW_DATABASE)
                            : Globals.getKeyPrefs().getKey(KeyBinding.IMPORT_INTO_CURRENT_DATABASE));
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileChooser = createImportFileChooser(
                    Globals.prefs.get(JabRefPreferences.IMPORT_WORKING_DIRECTORY));
            int result = fileChooser.showOpenDialog(frame);

            if (result != JFileChooser.APPROVE_OPTION) {
                return;
            }

            File file = fileChooser.getSelectedFile();
            if (file == null) {
                return;
            }

            FileFilter ff = fileChooser.getFileFilter();
            ImportFormat format = null;
            if (ff instanceof ImportFileFilter) {
                format = ((ImportFileFilter) ff).getImportFormat();
            }

            try {
                if (!file.exists()) {
                    // Warn that the file doesn't exists:
                    JOptionPane.showMessageDialog(frame,
                            Localization.lang("File not found") + ": '" + file.getName() + "'.",
                            Localization.lang("Import"), JOptionPane.ERROR_MESSAGE);
                    return;
                }
                ImportMenuItem imi = new ImportMenuItem(frame, openInNew, format);
                imi.automatedImport(Collections.singletonList(file.getAbsolutePath()));

                // Make sure we remember which filter was used, to set the default
                // for next time:
                if (format == null) {
                    Globals.prefs.put(JabRefPreferences.LAST_USED_IMPORT, "__all");
                } else {
                    Globals.prefs.put(JabRefPreferences.LAST_USED_IMPORT, format.getFormatName());
                }
                Globals.prefs.put(JabRefPreferences.IMPORT_WORKING_DIRECTORY, file.getParent());
            } catch (Exception ex) {
                LOGGER.warn("Problem with import format", ex);
            }

        }
    }

    return new ImportAction(frame, openInNew);
}

From source file:ca.sfu.federation.action.CreateProjectAction.java

/**
 * CreateProjectAction constructor.//  ww w  .java 2s.  c  om
 * @param Name Action name that will appear in menus.
 * @param MyIcon Action icon.
 * @param ToolTip Action description that will appear in Tool Tip.
 * @param MnemonicId Key mnemonic.
 */
public CreateProjectAction(String Name, Icon MyIcon, String ToolTip, Integer MnemonicId) {
    super(Name, MyIcon);
    this.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control N"));
    this.putValue(Action.LONG_DESCRIPTION, ToolTip);
    this.putValue(Action.MNEMONIC_KEY, MnemonicId);
    this.putValue(Action.SHORT_DESCRIPTION, ToolTip);
    this.putValue(Action.SMALL_ICON, MyIcon);
}

From source file:net.sf.jabref.importer.OpenDatabaseAction.java

public OpenDatabaseAction(JabRefFrame frame, boolean showDialog) {
    super(IconTheme.JabRefIcon.OPEN.getIcon());
    this.frame = frame;
    this.showDialog = showDialog;
    putValue(Action.NAME, Localization.menuTitle("Open database"));
    putValue(Action.ACCELERATOR_KEY, Globals.getKeyPrefs().getKey(KeyBinding.OPEN_DATABASE));
    putValue(Action.SHORT_DESCRIPTION, Localization.lang("Open BibTeX database"));
}