當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。