當前位置: 首頁>>代碼示例>>Java>>正文


Java JMenuItem.putClientProperty方法代碼示例

本文整理匯總了Java中javax.swing.JMenuItem.putClientProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java JMenuItem.putClientProperty方法的具體用法?Java JMenuItem.putClientProperty怎麽用?Java JMenuItem.putClientProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JMenuItem的用法示例。


在下文中一共展示了JMenuItem.putClientProperty方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configureMenuItem

import javax.swing.JMenuItem; //導入方法依賴的package包/類
private void configureMenuItem (JMenuItem item, String containerCtx, String action, ActionProvider provider, Map context) {
//        System.err.println("ConfigureMenuItem: " + containerCtx + "/" + action);
        item.setName(action);
        item.putClientProperty(KEY_ACTION, action);
        item.putClientProperty(KEY_CONTAINERCONTEXT, containerCtx);
        item.putClientProperty(KEY_CREATOR, this);
        item.setText(
            provider.getDisplayName(action, containerCtx));
        item.setToolTipText(provider.getDescription(action, containerCtx));
        int state = context == null ? ActionProvider.STATE_ENABLED | ActionProvider.STATE_VISIBLE :
            provider.getState (action, containerCtx, context);
        boolean enabled = (state & ActionProvider.STATE_ENABLED) != 0; 
        item.setEnabled(enabled);
        boolean visible = (state & ActionProvider.STATE_VISIBLE) != 0;
        //Intentionally use enabled property
        item.setVisible(enabled);
        item.setMnemonic(provider.getMnemonic(action, containerCtx));
        item.setDisplayedMnemonicIndex(provider.getMnemonicIndex(action, containerCtx));
        item.setIcon(provider.getIcon(action, containerCtx, BeanInfo.ICON_COLOR_16x16));
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:AbstractContextMenuFactory.java

示例2: configureMenuItem

import javax.swing.JMenuItem; //導入方法依賴的package包/類
private void configureMenuItem (JMenuItem item, String containerCtx, String action, ActionProvider provider, Map context) {
//        System.err.println("ConfigureMenuItem: " + containerCtx + "/" + action);
        item.setName(action);
        item.putClientProperty(KEY_ACTION, action);
        item.putClientProperty(KEY_CONTAINERCONTEXT, containerCtx);
        item.putClientProperty(KEY_CREATOR, this);
        item.setText(
            provider.getDisplayName(action, containerCtx));
//        System.err.println("  item text is " + item.getText());
        item.setToolTipText(provider.getDescription(action, containerCtx));
        int state = context == null ? ActionProvider.STATE_ENABLED | ActionProvider.STATE_VISIBLE :
            provider.getState (action, containerCtx, context);
        boolean enabled = (state & ActionProvider.STATE_ENABLED) != 0; 
//        System.err.println("action " + action + (enabled ? " enabled" : " disabled"));
        item.setEnabled(enabled);
        boolean visible = (state & ActionProvider.STATE_VISIBLE) != 0;
//        System.err.println("action " + action + (visible ? " visible" : " invisible"));
        item.setVisible(visible);
        item.setMnemonic(provider.getMnemonic(action, containerCtx));
        item.setDisplayedMnemonicIndex(provider.getMnemonicIndex(action, containerCtx));
        item.setIcon(provider.getIcon(action, containerCtx, BeanInfo.ICON_COLOR_16x16));
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:AbstractMenuFactory.java

示例3: setProperties

import javax.swing.JMenuItem; //導入方法依賴的package包/類
void setProperties(JMenuItem menuItem) {
    switch (type) {
        case CHECK_BOX_MENU_ITEM:
            menuItem.putClientProperty(CHECK_BOX_PROP, compDoNotCloseOnMouseClick);
            UIManager.put(CHECK_BOX_PROP, lafDoNotCloseOnMouseClick);
            break;
        case RADIO_BUTTON_MENU_ITEM:
            menuItem.putClientProperty(RADIO_BUTTON_PROP, compDoNotCloseOnMouseClick);
            UIManager.put(RADIO_BUTTON_PROP, lafDoNotCloseOnMouseClick);
            break;
        default:
            menuItem.putClientProperty(CHECK_BOX_PROP, compDoNotCloseOnMouseClick);
            menuItem.putClientProperty(RADIO_BUTTON_PROP, compDoNotCloseOnMouseClick);
            UIManager.put(CHECK_BOX_PROP, lafDoNotCloseOnMouseClick);
            UIManager.put(RADIO_BUTTON_PROP, lafDoNotCloseOnMouseClick);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:CloseOnMouseClickPropertyTest.java

示例4: getOrCreateMenuItem

import javax.swing.JMenuItem; //導入方法依賴的package包/類
private JMenuItem getOrCreateMenuItem(int type) {
    JMenuItem result = type == ActionProvider.ACTION_TYPE_ITEM ? new JMenuItem() :
        type == ActionProvider.ACTION_TYPE_SUBCONTEXT ? new JMenu() : null;
    if (type == ActionProvider.ACTION_TYPE_ITEM) {
        result.addActionListener (getItemListener());
    } else if (type == ActionProvider.ACTION_TYPE_SUBCONTEXT){
        //attachToMenu ((JMenu) result);
    }
    result.putClientProperty (KEY_CREATOR, this);
    return result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:AbstractContextMenuFactory.java

示例5: getOrCreateMenuItem

import javax.swing.JMenuItem; //導入方法依賴的package包/類
private JMenuItem getOrCreateMenuItem(int type) {
    JMenuItem result = type == ActionProvider.ACTION_TYPE_ITEM ? new JMenuItem() :
        type == ActionProvider.ACTION_TYPE_SUBCONTEXT ? new JMenu() : null;
    if (type == ActionProvider.ACTION_TYPE_ITEM) {
        result.addActionListener (getItemListener());
    } else if (type == ActionProvider.ACTION_TYPE_SUBCONTEXT){
        attachToMenu ((JMenu) result);
    }
    result.putClientProperty (KEY_CREATOR, this);
    return result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:AbstractMenuFactory.java

示例6: createMenuItems

import javax.swing.JMenuItem; //導入方法依賴的package包/類
public JMenuItem[] createMenuItems () {
    FiltersDescription filtersDesc = filters.getDescription();
    ArrayList menuItems = new ArrayList();
    for (int i = 0; i < filtersDesc.getFilterCount(); i++) {
        String filterName = filtersDesc.getName(i);
        JMenuItem menuItem = new JCheckBoxMenuItem(
                filtersDesc.getDisplayName(i), filters.isSelected(filterName)); 
        menuItem.addActionListener(this);
        menuItem.putClientProperty(PROP_FILTER_NAME, filterName);
        menuItems.add(menuItem);
    }
    return (JMenuItem[])menuItems.toArray(new JMenuItem[]{});
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:FilterActions.java

示例7: MenuBridge

import javax.swing.JMenuItem; //導入方法依賴的package包/類
/** Constructor.
* @param popup pop-up menu
*/
public MenuBridge(JMenuItem item, Action action, boolean popup) {
    super(item, action);
    this.popup = popup;
    
    if (popup) {
        prepareMargins(item, action);
    } else {
        // #40824 hack
        item.putClientProperty("menubridgeresizehack", this);

        // #40824 hack end.
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:Actions.java

示例8: addAction

import javax.swing.JMenuItem; //導入方法依賴的package包/類
protected void addAction(JTextComponent component, JPopupMenu popupMenu, Action action) {
    Lookup contextLookup = getContextLookup(component);
    
    // issue #69688
    EditorKit kit = component.getUI().getEditorKit(component);
    if (contextLookup == null && (kit instanceof NbEditorKit) &&
            ((NbEditorKit)kit).systemAction2editorAction.containsKey(action.getClass().getName())){
        addAction(component, popupMenu, (String) ((NbEditorKit)kit).systemAction2editorAction.get(action.getClass().getName()));
        return;
    }
    
    action = translateContextLookupAction(contextLookup, action);

    if (action != null) {
        JMenuItem item = createLocalizedMenuItem(action);
        if (item instanceof DynamicMenuContent) {
            Component[] cmps = ((DynamicMenuContent)item).getMenuPresenters();
            for (int i = 0; i < cmps.length; i++) {
                if(cmps[i] != null) {
                    popupMenu.add(cmps[i]);
                } else {
                    popupMenu.addSeparator();
                }
            }
        } else {
            if (Boolean.TRUE.equals(action.getValue(DynamicMenuContent.HIDE_WHEN_DISABLED)) && !action.isEnabled()) {
                return;
            }
            if (item == null) {
                LOG.log(Level.WARNING, "Null menu item produced by action {0}.", action);
            } else {
                item.setEnabled(action.isEnabled());
                Object helpID = action.getValue ("helpID"); // NOI18N
                if (helpID != null && (helpID instanceof String)) {
                    item.putClientProperty ("HelpID", helpID); // NOI18N
                }
                assignAccelerator(component.getKeymap(), action, item);
                debugPopupMenuItem(item, action);
                popupMenu.add(item);
            }
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:44,代碼來源:NbEditorKit.java

示例9: connect

import javax.swing.JMenuItem; //導入方法依賴的package包/類
/** Attaches menu item to an action.
 * You can supply an alternative implementation
 * for this method by implementing method
 * {@link ButtonActionConnector#connect(JMenuItem, Action, boolean)} and
 * registering an instance of {@link ButtonActionConnector} in the
 * default lookup. 
 * <p>
 * Since version 7.1 the action can also provide properties
 * "menuText" and "popupText" if one wants to use other text on the JMenuItem
 * than the name
 * of the action taken from Action.NAME. The popupText is checked only if the
 * popup parameter is true and takes the biggest precedence. The menuText is
 * tested everytime and takes precedence over standard <code>Action.NAME</code>
 * <p>
 * By default icons are not visible in popup menus. This can be configured
 * via <a href="@[email protected]#branding-USE_MNEMONICS">branding</a>.
 * 
 * @param item menu item
 * @param action action
 * @param popup create popup or menu item
 * @since 3.29
 */
public static void connect(JMenuItem item, Action action, boolean popup) {
    for (ButtonActionConnector bac : buttonActionConnectors()) {
        if (bac.connect(item, action, popup)) {
            return;
        }
    }
    Bridge b = new MenuBridge(item, action, popup);
    b.prepare();

    if (item instanceof Actions.MenuItem) {
        ((Actions.MenuItem)item).setBridge(b);
    }
    item.putClientProperty(DynamicMenuContent.HIDE_WHEN_DISABLED, action.getValue(DynamicMenuContent.HIDE_WHEN_DISABLED));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:37,代碼來源:Actions.java

示例10: setItemProject

import javax.swing.JMenuItem; //導入方法依賴的package包/類
/**
 * Set weakly-referenced project as item's client property.
 *
 * @param menuItem Menu item.
 * @param project The project.
 */
private static void setItemProject(JMenuItem menuItem, Project project) {
    menuItem.putClientProperty(PROJECT_KEY, new WeakReference<Project>(project));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:SetMainProject.java


注:本文中的javax.swing.JMenuItem.putClientProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。