Java Code Examples for javax.swing.JMenuItem#setVisible()

The following examples show how to use javax.swing.JMenuItem#setVisible() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractContextMenuFactory.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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));
    }
 
Example 2
Source File: AbstractMenuFactory.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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));
    }
 
Example 3
Source File: WebServiceClientActionGroup.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public JMenuItem getPopupPresenter() {
	Node[] activatedNodes = getActivatedNodes();
	if(activatedNodes.length == 1 && hasWebServiceClient()) {
		return new LazyMenu();
	}
	JMenuItem i = super.getPopupPresenter();
	i.setVisible(false);
	return i;
}
 
Example 4
Source File: ScriptAutoCompleteMenu.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
public void filterMenus(String txt) {
    String txtLc = txt.toLowerCase();
    for (JMenuItem menu : menus) {
        menu.setVisible(menu.getText().toLowerCase().startsWith(txtLc));
    }
    this.pack();
}
 
Example 5
Source File: ComboMenuBar.java    From ChatGameFontificator with The Unlicense 5 votes vote down vote up
private void setMenuItemFilterVisibility()
{
    for (JMenuItem menuFolder : allMenuItems.keySet())
    {
        final boolean menuFolderVisibility = !allMenuItems.get(menuFolder).isFiltered() && !menuFolder.getText().isEmpty();
        menuFolder.setVisible(menuFolderVisibility);
    }
}