本文整理了Java中javax.swing.Action.putValue()
方法的一些代码示例,展示了Action.putValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Action.putValue()
方法的具体详情如下:
包路径:javax.swing.Action
类名称:Action
方法名:putValue
暂无
代码示例来源:origin: skylot/jadx
openAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.open_action"));
openAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_DOWN_MASK));
saveAllAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.save_all"));
saveAllAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK));
exportAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.export_gradle"));
exportAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_DOWN_MASK));
prefsAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.preferences"));
prefsAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_P,
KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK));
syncAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.sync"));
syncAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_DOWN_MASK));
textSearchAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.text_search"));
textSearchAction.putValue(Action.ACCELERATOR_KEY,
getKeyStroke(KeyEvent.VK_F, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK));
clsSearchAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.class_search"));
clsSearchAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK));
deobfAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("preferences.deobfuscation"));
deobfAction.putValue(Action.ACCELERATOR_KEY,
getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK));
logAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.log"));
logAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_L,
代码示例来源:origin: bobbylight/RSyntaxTextArea
tempAction.putValue(Action.NAME, name);
tempAction.putValue(Action.SHORT_DESCRIPTION, name);
tempAction.putValue(Action.ACCELERATOR_KEY, accelerator);
tempAction.putValue(Action.MNEMONIC_KEY, mnemonic);
代码示例来源:origin: stackoverflow.com
Action closeWindow = new AbstractAction("Close Window") {
@Override public void actionPerformed(ActionEvent e) {
// window closing code here
}
};
closeWindow.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
KeyEvent.VK_W, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
代码示例来源:origin: org.netbeans.api/org-openide-awt
private void syncActionDelegateProperty(String propertyName, Action actionDelegate) {
Object value = extractCommonAttribute(map, propertyName);
Object delegateValue = actionDelegate.getValue(propertyName);
if (value != null) {
if (delegateValue == null) {
actionDelegate.putValue(propertyName, value);
} else {
if (!delegateValue.equals(value)) { // Values differ
LOG.log(Level.FINE, "Value of property \"{0}\" of AlwaysEnabledAction " +
"is \"{1}\" but delegate {2} has \"{3}\"",
new Object[] {propertyName, value, delegate, delegateValue});
}
}
} // else either both values are null or
// this has null and delegate has non-null which is probably fine (declarer does not care)
}
代码示例来源:origin: stackoverflow.com
// create an Action doing what you want
Action action = new AbstractAction("doSomething") {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("triggered the action");
}
};
// configure the Action with the accelerator (aka: short cut)
action.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control S"));
// create a button, configured with the Action
JButton toolBarButton = new JButton(action);
// manually register the accelerator in the button's component input map
toolBarButton.getActionMap().put("myAction", action);
toolBarButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
(KeyStroke) action.getValue(Action.ACCELERATOR_KEY), "myAction");
代码示例来源:origin: bobbylight/RSyntaxTextArea
a.setEnabled(true);
text = getUndoPresentationName();
a.putValue(Action.NAME, text);
a.putValue(Action.SHORT_DESCRIPTION, text);
a.setEnabled(false);
text = cantUndoText;
a.putValue(Action.NAME, text);
a.putValue(Action.SHORT_DESCRIPTION, text);
a.setEnabled(true);
text = getRedoPresentationName();
a.putValue(Action.NAME, text);
a.putValue(Action.SHORT_DESCRIPTION, text);
a.setEnabled(false);
text = cantRedoText;
a.putValue(Action.NAME, text);
a.putValue(Action.SHORT_DESCRIPTION, text);
代码示例来源:origin: org.netbeans.api/org-openide-awt
/**
* Associates an {@link Action#ACCELERATOR_KEY} with an action based on a declared shortcut.
* If an instance of {@link AcceleratorBinding} can be found in default lookup,
* it will be used to determine the binding. Otherwise nothing is done.
* @param action an action defined in layers
* @param definingFile instance file defining the action
*/
public static void setAccelerator(Action action, FileObject definingFile) {
for (AcceleratorBinding bnd : ALL.all()) {
KeyStroke key = bnd.keyStrokeForAction(action, definingFile);
if (key != null) {
action.putValue(Action.ACCELERATOR_KEY, key);
break;
}
}
}
代码示例来源:origin: stackoverflow.com
searchPersonAction.putValue(Action.NAME, "Search");
代码示例来源:origin: chatty/chatty
/**
* Removes the hotkeys from all actions, so only those that are still set
* are readded.
*/
private void removeHotkeysFromActions() {
for (HotkeyAction action : actions.values()) {
action.action.putValue(Action.ACCELERATOR_KEY, null);
}
}
代码示例来源:origin: openpnp/openpnp
private void updateStartStopButton(boolean enabled) {
startStopMachineAction.putValue(Action.NAME, enabled ? Translations.getString("MachineControls.Action.Stop") : Translations.getString("MachineControls.Action.Start")); //$NON-NLS-1$ //$NON-NLS-2$
startStopMachineAction.putValue(Action.SMALL_ICON,
enabled ? Icons.powerOff : Icons.powerOn);
homeAction.putValue(Action.SMALL_ICON, enabled ? Icons.homeWarning : Icons.home);
}
代码示例来源:origin: stackoverflow.com
Action exit = new AbstractAction() {
private static final long serialVersionUID = -2581717261367873054L;
@Override
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
};
exit.putValue(Action.NAME, "Exit");
exit.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_X);
JButton exitButton = new JButton(exit);
JMenuItem exitItem = new JMenuItem(exit);
代码示例来源:origin: JetBrains/jediterm
public static void assignMnemonic(@NotNull String text, @NotNull Action action) {
int mnemoPos = text.indexOf('&');
if (mnemoPos >= 0 && mnemoPos < text.length() - 2) {
String mnemoChar = text.substring(mnemoPos + 1, mnemoPos + 2).trim();
if (mnemoChar.length() == 1) {
action.putValue(Action.MNEMONIC_KEY, Integer.valueOf(mnemoChar.charAt(0)));
}
}
}
代码示例来源:origin: igniterealtime/Spark
public void poppingUp(Object component, JPopupMenu popup) {
Action saveAction = new AbstractAction() {
private static final long serialVersionUID = -3582301239832606653L;
public void actionPerformed(ActionEvent actionEvent) {
saveTranscript();
}
};
saveAction.putValue(Action.NAME, Res.getString("action.save"));
saveAction.putValue(Action.SMALL_ICON, SparkRes.getImageIcon(SparkRes.SAVE_AS_16x16));
popup.add(saveAction);
}
代码示例来源:origin: stackoverflow.com
Action doLog = new AbstractAction("Dummny log!") {
@Override
public void actionPerformed(ActionEvent e) {
LOG.info("doing: " + getValue(Action.NAME));
}
};
doLog.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("F5"));
JMenu menu = new JMenu("dummy");
menu.add(doLog);
frame.getJMenuBar().add(menu);
代码示例来源:origin: JetBrains/jediterm
public static void setActionNameAndMnemonic(@NotNull String text, @NotNull Action action) {
assignMnemonic(text, action);
text = text.replaceAll("&", "");
action.putValue(Action.NAME, text);
}
代码示例来源:origin: mucommander/mucommander
/**
* Sets the help topic this button will open when clicked, <code>null</code> to open the base documentation URL.
*
* @param helpTopic the help topic this button will open when clicked, <code>null</code> to open the base documentation URL
*/
public void setHelpTopic(String helpTopic) {
getAction().putValue(GoToDocumentationAction.TOPIC_PROPERTY_KEY, helpTopic);
}
}
代码示例来源:origin: org.nuiton.jaxx/jaxx-runtime
protected void acceptEvent(MouseEvent e, JXLayer<? extends JComponent> l) {
if (acceptAction != null) {
acceptAction.putValue("layer", l);
Component source = l.getView();
acceptAction.actionPerformed(new ActionEvent(source, 0, "accept"));
}
}
代码示例来源:origin: freeplane/freeplane
public static void addKeyActionToDialog(final JDialog dialog, final Action action, final String keyStroke,
final String actionId) {
action.putValue(Action.NAME, actionId);
dialog.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(keyStroke),
action.getValue(Action.NAME));
dialog.getRootPane().getActionMap().put(action.getValue(Action.NAME), action);
}
代码示例来源:origin: openpnp/openpnp
@Override
public void actionPerformed(ActionEvent arg0) {
UiUtils.submitUiMachineTask(() -> {
Machine machine = Configuration.get().getMachine();
machine.home();
homeAction.putValue(Action.SMALL_ICON, Icons.home);
});
}
};
代码示例来源:origin: jawi/ols
/**
* {@inheritDoc}
*/
@Override
protected JMenuItem createMenuItem( final String aDeviceName )
{
final Action action = this.controller.getAction( SelectDeviceAction.getID( aDeviceName ) );
action.putValue( Action.SELECTED_KEY, isDeviceToBeSelected( aDeviceName ) );
return new JRadioButtonMenuItem( action );
}
内容来源于网络,如有侵权,请联系作者删除!