当前位置: 首页>>代码示例>>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;未经允许,请勿转载。