List of usage examples for javax.swing Action MNEMONIC_KEY
String MNEMONIC_KEY
To view the source code for javax.swing Action MNEMONIC_KEY.
Click Source Link
Integer
that corresponds to one of the KeyEvent
key codes. From source file:org.colombbus.tangara.commons.resinject.ActionInjecter.java
private void injectMnemonicKey() { String mnemonicKey = actionKey + MNEMONIC_KEY_SUFFIX; if (classResource.containsKey(mnemonicKey)) { KeyStroke mnemonicKeyStroke = classResource.getKeyStroke(mnemonicKey); int keyEventValue = mnemonicKeyStroke.getKeyCode(); action.putValue(Action.MNEMONIC_KEY, new Integer(keyEventValue)); }/*from ww w . j a v a 2 s .c o m*/ }
From source file:org.jcurl.demo.tactics.old.ActionRegistry.java
/** Create a disabled {@link Action}. */ private Action createAction(final Object controller, final Method m, final JCAction a) { final Action ac = new AbstractAction() { private static final long serialVersionUID = 2349356576661476730L; public void actionPerformed(final ActionEvent e) { try { m.invoke(controller, (Object[]) null); } catch (final IllegalArgumentException e1) { throw new RuntimeException("Unhandled", e1); } catch (final IllegalAccessException e1) { throw new RuntimeException("Unhandled", e1); } catch (final InvocationTargetException e1) { throw new RuntimeException("Unhandled", e1); }//from w w w . j a v a2 s .co m } }; ac.putValue(Action.NAME, stripMnemonic(a.title())); ac.putValue(Action.ACCELERATOR_KEY, findAccelerator(a.accelerator())); if (false) { final Character mne = findMnemonic(a.title()); if (mne != null) ac.putValue(Action.MNEMONIC_KEY, KeyStroke.getKeyStroke(mne)); } ac.setEnabled(false); return ac; }
From source file:org.languagetool.gui.Main.java
private JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu(getLabel("guiMenuFile")); fileMenu.setMnemonic(getMnemonic("guiMenuFile")); JMenu editMenu = new JMenu(getLabel("guiMenuEdit")); editMenu.setMnemonic(getMnemonic("guiMenuEdit")); JMenu grammarMenu = new JMenu(getLabel("guiMenuGrammar")); grammarMenu.setMnemonic(getMnemonic("guiMenuGrammar")); JMenu helpMenu = new JMenu(getLabel("guiMenuHelp")); helpMenu.setMnemonic(getMnemonic("guiMenuHelp")); fileMenu.add(openAction);//from w w w . ja va 2 s . com fileMenu.add(saveAction); fileMenu.add(saveAsAction); recentFilesMenu = new JMenu(getLabel("guiMenuRecentFiles")); recentFilesMenu.setMnemonic(getMnemonic("guiMenuRecentFiles")); fileMenu.add(recentFilesMenu); updateRecentFilesMenu(); fileMenu.addSeparator(); fileMenu.add(new HideAction()); fileMenu.addSeparator(); fileMenu.add(new QuitAction()); grammarMenu.add(checkAction); JCheckBoxMenuItem item = new JCheckBoxMenuItem(autoCheckAction); grammarMenu.add(item); JCheckBoxMenuItem showResult = new JCheckBoxMenuItem(showResultAction); grammarMenu.add(showResult); grammarMenu.add(new CheckClipboardAction()); grammarMenu.add(new TagTextAction()); grammarMenu.add(new AddRulesAction()); grammarMenu.add(new OptionsAction()); grammarMenu.add(new SelectFontAction()); JMenu lafMenu = new JMenu(messages.getString("guiLookAndFeelMenu")); UIManager.LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels(); ButtonGroup buttonGroup = new ButtonGroup(); for (UIManager.LookAndFeelInfo laf : lafInfo) { if (!"Nimbus".equals(laf.getName())) { continue; } addLookAndFeelMenuItem(lafMenu, laf, buttonGroup); } for (UIManager.LookAndFeelInfo laf : lafInfo) { if ("Nimbus".equals(laf.getName())) { continue; } addLookAndFeelMenuItem(lafMenu, laf, buttonGroup); } grammarMenu.add(lafMenu); helpMenu.add(new AboutAction()); undoRedo.undoAction.putValue(Action.NAME, getLabel("guiMenuUndo")); undoRedo.undoAction.putValue(Action.MNEMONIC_KEY, getMnemonic("guiMenuUndo")); undoRedo.redoAction.putValue(Action.NAME, getLabel("guiMenuRedo")); undoRedo.redoAction.putValue(Action.MNEMONIC_KEY, getMnemonic("guiMenuRedo")); editMenu.add(undoRedo.undoAction); editMenu.add(undoRedo.redoAction); editMenu.addSeparator(); Action cutAction = new DefaultEditorKit.CutAction(); cutAction.putValue(Action.SMALL_ICON, getImageIcon("sc_cut.png")); cutAction.putValue(Action.LARGE_ICON_KEY, getImageIcon("lc_cut.png")); cutAction.putValue(Action.NAME, getLabel("guiMenuCut")); cutAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_T); editMenu.add(cutAction); Action copyAction = new DefaultEditorKit.CopyAction(); copyAction.putValue(Action.SMALL_ICON, getImageIcon("sc_copy.png")); copyAction.putValue(Action.LARGE_ICON_KEY, getImageIcon("lc_copy.png")); copyAction.putValue(Action.NAME, getLabel("guiMenuCopy")); copyAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_C); editMenu.add(copyAction); Action pasteAction = new DefaultEditorKit.PasteAction(); pasteAction.putValue(Action.SMALL_ICON, getImageIcon("sc_paste.png")); pasteAction.putValue(Action.LARGE_ICON_KEY, getImageIcon("lc_paste.png")); pasteAction.putValue(Action.NAME, getLabel("guiMenuPaste")); pasteAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_P); editMenu.add(pasteAction); editMenu.addSeparator(); editMenu.add(new SelectAllAction()); menuBar.add(fileMenu); menuBar.add(editMenu); menuBar.add(grammarMenu); menuBar.add(helpMenu); return menuBar; }
From source file:org.nuclos.client.main.MainController.java
private Action createEntityAction(EntityMetaDataVO entitymetavo, String label, final boolean isNew, final Long processId, final String customUsage) { String entity = entitymetavo.getEntity(); if (!getSecurityCache().isReadAllowedForEntity(entity)) { return null; }/* ww w. jav a 2s . c o m*/ if (isNew && entitymetavo.isStateModel() && !getSecurityCache().isNewAllowedForModuleAndProcess(IdUtils.unsafeToId(entitymetavo.getId()), IdUtils.unsafeToId(processId))) { return null; } Action action = new AbstractAction() { @Override public void actionPerformed(ActionEvent evt) { cmdCollectMasterData(evt, isNew, processId, customUsage); } }; Pair<String, Character> nameAndMnemonic = MenuGenerator.getMnemonic(label); action.putValue(Action.NAME, customUsage == null ? nameAndMnemonic.x : String.format("%s (%s)", nameAndMnemonic.x, customUsage)); if (nameAndMnemonic.y != null) { action.putValue(Action.MNEMONIC_KEY, (int) nameAndMnemonic.y.charValue()); } action.setEnabled(true); action.putValue(Action.SMALL_ICON, MainFrame.resizeAndCacheTabIcon(Main.getInstance().getMainFrame().getEntityIcon(entity))); action.putValue(Action.ACTION_COMMAND_KEY, entity); if (!isNew && processId == null) { if (!StringUtils.isNullOrEmpty(entitymetavo.getAccelerator()) && entitymetavo.getAcceleratorModifier() != null) { int keycode = entitymetavo.getAccelerator().charAt(0); if (keycode > 90) keycode -= 32; action.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(keycode, entitymetavo.getAcceleratorModifier().intValue())); } else if (!StringUtils.isNullOrEmpty(entitymetavo.getAccelerator())) { action.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(entitymetavo.getAccelerator().charAt(0))); } } return action; }
From source file:org.pentaho.reporting.designer.core.actions.global.LaunchHelpAction.java
public LaunchHelpAction() { putValue(Action.NAME, ActionMessages.getString("LaunchHelpAction.Text")); putValue(Action.SHORT_DESCRIPTION, ActionMessages.getString("LaunchHelpAction.Description")); putValue(Action.MNEMONIC_KEY, ActionMessages.getOptionalMnemonic("LaunchHelpAction.Mnemonic")); putValue(Action.ACCELERATOR_KEY, ActionMessages.getOptionalKeyStroke("LaunchHelpAction.Accelerator")); }
From source file:org.pentaho.reporting.designer.core.actions.global.ScreenCaptureAction.java
public ScreenCaptureAction() { putValue(Action.NAME, ActionMessages.getString("ScreenCaptureAction.Text")); putValue(Action.SHORT_DESCRIPTION, ActionMessages.getString("ScreenCaptureAction.Description")); putValue(Action.MNEMONIC_KEY, ActionMessages.getOptionalMnemonic("ScreenCaptureAction.Mnemonic")); //putValue(Action.ACCELERATOR_KEY, ActionMessages.getOptionalKeyStroke("ScreenCaptureAction.Accelerator")); installGlobally();// w ww. java2 s.c o m }
From source file:org.pentaho.reporting.designer.core.xul.ActionSwingMenuitem.java
private void refreshMnemonic(final Action actionImpl) { final Object o = actionImpl.getValue(Action.MNEMONIC_KEY); if (o != null) { if (o instanceof Character) { final Character c = (Character) o; setAccesskey(String.valueOf(c.charValue())); } else if (o instanceof Integer) { final Integer c = (Integer) o; setAccesskey(String.valueOf(c.intValue())); }/*from ww w.j ava2s. c o m*/ } else { setAccesskey("\0"); } }
From source file:org.pentaho.reporting.engine.classic.core.modules.gui.base.actions.ExportAction.java
/** * Defines an <code>Action</code> object with a default description string and default icon. *///from w w w. j av a2 s . c o m public ExportAction(final ExportActionPlugin actionPlugin, final PreviewPane previewPane) { if (actionPlugin == null) { throw new NullPointerException(); } if (previewPane == null) { throw new NullPointerException(); } this.actionPlugin = actionPlugin; this.previewPane = previewPane; putValue(Action.NAME, actionPlugin.getDisplayName()); putValue(Action.SHORT_DESCRIPTION, actionPlugin.getShortDescription()); putValue(Action.ACCELERATOR_KEY, actionPlugin.getAcceleratorKey()); putValue(Action.MNEMONIC_KEY, actionPlugin.getMnemonicKey()); putValue(Action.SMALL_ICON, actionPlugin.getSmallIcon()); putValue(SwingCommonModule.LARGE_ICON_PROPERTY, actionPlugin.getLargeIcon()); this.actionPlugin.addPropertyChangeListener("enabled", new EnableChangeListener()); //$NON-NLS-1$ setEnabled(actionPlugin.isEnabled()); }
From source file:pl.otros.logview.gui.actions.MarkAllFoundAction.java
public MarkAllFoundAction(OtrosApplication otrosApplication) { super(otrosApplication); this.putValue(Action.NAME, "Mark all found"); this.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_A); this.putValue(SMALL_ICON, Icons.AUTOMATIC_MARKERS); }
From source file:ro.nextreports.designer.action.chart.OpenChartAction.java
public OpenChartAction(boolean fullName) { if (fullName) { putValue(Action.NAME, I18NSupport.getString("open.chart")); } else {//from w w w .j av a2 s . c om putValue(Action.NAME, I18NSupport.getString("open.chart.small")); } Icon icon = ImageUtil.getImageIcon("chart_open"); putValue(Action.SMALL_ICON, icon); putValue(Action.MNEMONIC_KEY, ShortcutsUtil.getMnemonic("chart.open.mnemonic", new Integer('A'))); putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(ShortcutsUtil.getShortcut("chart.open.accelerator", "control A"))); putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("open.chart")); putValue(Action.LONG_DESCRIPTION, I18NSupport.getString("open.chart")); }