当前位置: 首页>>代码示例>>Java>>正文


Java Action.putValue方法代码示例

本文整理汇总了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));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:DefaultAWTBridgeTest.java

示例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)
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:AbstractEditorAction.java

示例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()
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:AbstractEditorAction.java

示例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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ActionsTest.java

示例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;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:15,代码来源:ModelPropertiesDialog.java

示例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);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:NbEditorToolBar.java

示例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));
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:KeyBindingsUpdater.java

示例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");
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ContextActionTest.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:NbmActionGoalProvider.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:DebuggerAction.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:Actions.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:NbEditorKit.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:Actions.java

示例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"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ModulesNode.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:Actions.java


注:本文中的javax.swing.Action.putValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。