本文整理汇总了Java中javax.swing.Action.putValue方法的典型用法代码示例。如果您正苦于以下问题:Java Action.putValue方法的具体用法?Java Action.putValue怎么用?Java Action.putValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.Action
的用法示例。
在下文中一共展示了Action.putValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testHideWhenDisabled
import javax.swing.Action; //导入方法依赖的package包/类
public void testHideWhenDisabled() throws Exception {
class NoOpAction extends AbstractAction {
NoOpAction(String n) {
super(n);
}
public @Override void actionPerformed(ActionEvent e) {}
}
Action a = new NoOpAction("a1");
assertEquals(Collections.singletonList("a1"), popupMenu(a));
a = new NoOpAction("a2");
a.setEnabled(false);
assertEquals(Collections.singletonList("a2[disabled]"), popupMenu(a));
a = new NoOpAction("a3");
a.putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
assertEquals(Collections.singletonList("a3"), popupMenu(a));
a = new NoOpAction("a4");
a.putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
a.setEnabled(false);
assertEquals(Collections.emptyList(), popupMenu(a));
}
示例2: putValue
import javax.swing.Action; //导入方法依赖的package包/类
@Override
public final void putValue(String key, Object value) {
Action dAction = delegateAction;
// Delegate whole putValue() if delegateAction already exists
if (dAction != null && dAction != UNITIALIZED_ACTION) {
dAction.putValue(key, value);
return;
}
if (value == null && properties == null) { // Prevent NPE from super(null) in constructor
return;
}
Object oldValue;
if ("enabled" == key) { // Same == in AbstractAction
oldValue = enabled;
enabled = Boolean.TRUE.equals(value);
} else {
synchronized (properties) {
oldValue = properties.put(key, (value != null) ? value : MASK_NULL_VALUE);
}
}
firePropertyChange(key, oldValue, value); // Checks whether oldValue.equals(value)
}
示例3: transferProperties
import javax.swing.Action; //导入方法依赖的package包/类
private void transferProperties(Action dAction) {
boolean log = LOG.isLoggable(Level.FINE);
if (log) {
LOG.fine("Transfer properties into " + dAction + '\n'); // NOI18N
}
synchronized (properties) {
for (Map.Entry<String,Object> entry : properties.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (value != MASK_NULL_VALUE) { // Allow to call createValue() for the property
if (log) {
LOG.fine(" key=" + key + ", value=" + value + '\n'); // NOI18N
}
dAction.putValue(key, value);
}
}
}
// Enabled status will be handled later in getDelegateAction()
}
示例4: testPopupTextIsTaken
import javax.swing.Action; //导入方法依赖的package包/类
public void testPopupTextIsTaken() throws Exception {
Action action = new ActionsTest.TestAction();
JMenuItem item = new JMenuItem();
JMenu jmenu = new JMenu();
jmenu.addNotify();
assertTrue("Peer created", jmenu.isDisplayable());
jmenu.getPopupMenu().addNotify();
assertTrue("Peer for popup", jmenu.getPopupMenu().isDisplayable());
action.putValue("popupText", "&Ahoj");
action.putValue("menuText", "&Ble");
action.putValue(action.NAME, "&Mle");
Actions.connect(item, action, true);
assertEquals(Utilities.isMac() ? 0 : 'A', item.getMnemonic());
assertEquals("Ahoj", item.getText());
}
示例5: createPopupMenu
import javax.swing.Action; //导入方法依赖的package包/类
private JPopupMenu createPopupMenu() {
JPopupMenu menu = new JPopupMenu();
for (Action action : getActions()) {
if (action == null)
menu.addSeparator();
else {
action.putValue(Action.NAME, GlobalResourcesManager
.getString((String) action
.getValue(Action.ACTION_COMMAND_KEY)));
menu.add(action);
}
}
return menu;
}
示例6: updateIcon
import javax.swing.Action; //导入方法依赖的package包/类
private static void updateIcon(Action a) {
Object icon = a.getValue(Action.SMALL_ICON);
if (icon == null) {
String resourceId = (String)a.getValue(BaseAction.ICON_RESOURCE_PROPERTY);
if (resourceId != null) {
ImageIcon img = ImageUtilities.loadImageIcon(resourceId, true);
if (img != null) {
a.putValue(Action.SMALL_ICON, img);
}
}
}
}
示例7: updateKits
import javax.swing.Action; //导入方法依赖的package包/类
private static void updateKits(Map<String,List<List<KeyStroke>>> actionName2binding, List<KitReference> kitRefs) {
// Update kits without locks (a.putValue() is done)
for (KitReference kitRef : kitRefs) {
EditorKit kit = kitRef.get();
if (kit == null) { // Might be null since this is a copy of orig. list
continue;
}
Action[] actions = kit.getActions();
for (int i = 0; i < actions.length; i++) {
Action a = actions[i];
String actionName = (String) a.getValue(Action.NAME);
@SuppressWarnings("unchecked")
List<List<KeyStroke>> origAccels = (List<List<KeyStroke>>)
a.getValue(AbstractEditorAction.MULTI_ACCELERATOR_LIST_KEY);
List<List<KeyStroke>> accels = actionName2binding.get(actionName);
if (accels == null) {
accels = Collections.emptyList();
}
if (origAccels == null || !origAccels.equals(accels)) {
a.putValue(AbstractEditorAction.MULTI_ACCELERATOR_LIST_KEY, accels);
if (accels.size() > 0) {
// First keystroke of first multi-key accelerator in the list
a.putValue(Action.ACCELERATOR_KEY, accels.get(0).get(0));
}
}
}
}
}
示例8: change
import javax.swing.Action; //导入方法依赖的package包/类
@Override
protected void change(Collection<? extends OtherThing> collection, Action instance) {
if (collection.size() == 0) {
instance.putValue(NAME, "Do something else ");
} else if (collection.size() == 1) {
instance.putValue(NAME, "Do something else to " + collection.iterator().next());
} else {
instance.putValue(NAME, "Do something else to " + collection.size() + " OtherThings");
}
}
示例9: createReloadTargetAction
import javax.swing.Action; //导入方法依赖的package包/类
@ActionID(id = "org.netbeans.modules.maven.apisupport.NBMReloadTarget", category = "Project")
@ActionRegistration(displayName = "#ACT_NBM_Reload_Target", lazy=false)
@ActionReference(position = 1225, path = "Projects/org-netbeans-modules-maven/Actions")
@Messages("ACT_NBM_Reload_Target=Reload in Target Platform")
public static Action createReloadTargetAction() {
Action a = ProjectSensitiveActions.projectCommandAction(RELOAD_TARGET, ACT_NBM_Reload_Target(), null);
a.putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
return a;
}
示例10: createDebugTestFileAction
import javax.swing.Action; //导入方法依赖的package包/类
public static Action createDebugTestFileAction() {
Action a = FileSensitiveActions.fileCommandAction(
ActionProvider.COMMAND_DEBUG_TEST_SINGLE,
NbBundle.getMessage(DebuggerAction.class, "LBL_DebugTestSingleAction_Name"),
ImageUtilities.loadImageIcon("org/netbeans/modules/debugger/resources/debugTestSingle.png", true));
a.putValue("iconBase","org/netbeans/modules/debugger/resources/debugTestSingle.png"); //NOI18N
a.putValue("noIconInMenu", true); //NOI18N
return a;
}
示例11: cleanMainProject
import javax.swing.Action; //导入方法依赖的package包/类
public static Action cleanMainProject() {
Action a = new MainProjectAction(
ActionProvider.COMMAND_CLEAN,
NbBundle.getMessage(Actions.class, "LBL_CleanMainProjectAction_Name" ),null); //NOI18N
a.putValue("iconBase","org/netbeans/modules/project/ui/resources/cleanProject.gif"); //NOI18N
return a;
}
示例12: addSystemActionMapping
import javax.swing.Action; //导入方法依赖的package包/类
protected void addSystemActionMapping(String editorActionName, Class systemActionClass) {
Action a = getActionByName(editorActionName);
if (a != null) {
a.putValue(SYSTEM_ACTION_CLASS_NAME_PROPERTY, systemActionClass.getName());
}
systemAction2editorAction.put(systemActionClass.getName(), editorActionName);
}
示例13: buildProject
import javax.swing.Action; //导入方法依赖的package包/类
public static Action buildProject() {
Action a = new ProjectAction (
ActionProvider.COMMAND_BUILD,
NbBundle.getMessage(Actions.class, "LBL_BuildProjectAction_Name"),
NbBundle.getMessage(Actions.class, "LBL_BuildProjectAction_Name_popup"),
null,
null );
a.putValue("iconBase","org/netbeans/modules/project/ui/resources/buildCurrentProject.gif"); //NOI18N
return a;
}
示例14: actionPerformed
import javax.swing.Action; //导入方法依赖的package包/类
@Override public void actionPerformed(ActionEvent e) {
Action act = CommonProjectActions.newProjectAction();
act.putValue("PRESELECT_CATEGORY" /*ProjectTemplates.PRESELECT_CATEGORY */, "Maven2");
act.putValue(CommonProjectActions.PROJECT_PARENT_FOLDER, proj.getPOMFile().getParentFile());
act.putValue("initialValueProperties", new String[] {"groupId", "version"});
act.putValue("groupId", proj.getOriginalMavenProject().getGroupId());
act.putValue("version", proj.getOriginalMavenProject().getVersion());
act.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "actionPerformed"));
}
示例15: rebuildProject
import javax.swing.Action; //导入方法依赖的package包/类
public static Action rebuildProject() {
Action a = new ProjectAction(
ActionProvider.COMMAND_REBUILD,
NbBundle.getMessage(Actions.class, "LBL_RebuildProjectAction_Name"),
NbBundle.getMessage(Actions.class, "LBL_RebuildProjectAction_Name_popup"),
null,
null );
a.putValue("iconBase","org/netbeans/modules/project/ui/resources/rebuildCurrentProject.gif"); //NOI18N
return a;
}