javax.swing.JCheckBoxMenuItem Java Examples

The following examples show how to use javax.swing.JCheckBoxMenuItem. 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: bug8031573.java    From dragonwell8_jdk with GNU General Public License v2.0 7 votes vote down vote up
@Override
public void init() {
    try {
        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                JMenuBar bar = new JMenuBar();
                JMenu menu = new JMenu("Menu");
                JCheckBoxMenuItem checkBoxMenuItem
                        = new JCheckBoxMenuItem("JCheckBoxMenuItem");
                checkBoxMenuItem.setSelected(true);
                menu.add(checkBoxMenuItem);
                bar.add(menu);
                setJMenuBar(bar);
            }
        });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #2
Source File: CGraphWindowMenuBar.java    From binnavi with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new menu bar for a given graph.
 *
 * @param model Contains the information about the displayed graph the menu refers to.
 * @param viewSwitcher Toggles between the different graph panel perspectives.
 */
public CGraphWindowMenuBar(final CGraphModel model, final IViewSwitcher viewSwitcher) {
  Preconditions.checkNotNull(model, "IE01626: Model argument can not be null");

  m_model = model;

  m_actionSave = new CActionSave(model.getParent(), model.getGraph());
  final JCheckBoxMenuItem autoLayoutMenu =
      new JCheckBoxMenuItem(new CActionAutomaticLayouting(model.getGraph()));
  final JCheckBoxMenuItem proximityBrowsingMenu = new JCheckBoxMenuItem(CActionProxy.proxy(
      new CActionProximityBrowsing(model.getParent(), model.getGraph())));

  add(new CViewMenu(model.getParent(), model.getGraphPanel(), model.getGraph(), model
      .getViewContainer(), m_actionSave));
  add(new CGraphMenu(model.getParent(), model.getGraph(), model.getViewContainer(),
      proximityBrowsingMenu, autoLayoutMenu));
  add(m_selectionMenu = new CSelectionMenu(model));
  add(new CSearchMenu(model.getGraph()));
  add(m_pluginsMenu = new CPluginsMenu(model));
  add(new CWindowsMenu(model.getParent(), viewSwitcher));

  m_synchronizer = new CGraphWindowMenuBarSynchronizer(
      model.getGraph().getSettings(), proximityBrowsingMenu, autoLayoutMenu);

  updateGui();
}
 
Example #3
Source File: FileModeMenu.java    From openAGV with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param appState Stores the application's current mode of operation.
 * @param view The application's main view.
 * @param actionMap The application's action map.
 */
@Inject
public FileModeMenu(final ApplicationState appState,
                    final OpenTCSView view,
                    final ViewActionMap actionMap) {
  super(labels.getString("fileModeMenu.text"));
  requireNonNull(view, "view");
  requireNonNull(actionMap, "actionMap");

  final ButtonGroup modeButtonGroup = new ButtonGroup();

  modellingModeItem = new JCheckBoxMenuItem(actionMap.get(SwitchToModellingAction.ID));
  add(modellingModeItem);
  modeButtonGroup.add(modellingModeItem);

  operatingModeItem = new JCheckBoxMenuItem(actionMap.get(SwitchToOperatingAction.ID));
  add(operatingModeItem);
  modeButtonGroup.add(operatingModeItem);
}
 
Example #4
Source File: AbstractQuickSearchComboBar.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void maybeShowPopup (MouseEvent evt) {
    if (evt != null && !SwingUtilities.isLeftMouseButton(evt)) {
        return;
    }

    JPopupMenu pm = new JPopupMenu();
    final Set<ProviderModel.Category> evalCats =
            new LinkedHashSet<ProviderModel.Category>();
    evalCats.addAll(CommandEvaluator.getEvalCats());
    JMenuItem allCats = new AllMenuItem(evalCats);
    pm.add(allCats);

    for (ProviderModel.Category cat : ProviderModel.getInstance().getCategories()) {
        if (!CommandEvaluator.RECENT.equals(cat.getName())) {
            JCheckBoxMenuItem item = new CategoryCheckBoxMenuItem(cat,
                    evalCats);
            pm.add(item);
        }
    }

    pm.show(getInnerComponent(), 0, getInnerComponent().getHeight() - 1);
}
 
Example #5
Source File: NbEditorKit.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public @Override JMenuItem getPopupMenuItem(JTextComponent target) {
    Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
    boolean toolbarVisible = prefs.getBoolean(SimpleValueNames.TOOLBAR_VISIBLE_PROP, EditorPreferencesDefaults.defaultToolbarVisible);
    
    JCheckBoxMenuItem item = new JCheckBoxMenuItem(
        NbBundle.getBundle(ToggleToolbarAction.class).getString("PROP_base_toolbarVisible"), //NOI18N
        toolbarVisible);
    
    item.addItemListener( new ItemListener() {
        public @Override void itemStateChanged(ItemEvent e) {
            actionPerformed(null,null);
        }
    });
    
    return item;
}
 
Example #6
Source File: ViewMenu.java    From triplea with GNU General Public License v3.0 6 votes vote down vote up
private void addShowMapDetails() {
  showMapDetails = new JCheckBoxMenuItem("Show Map Details");
  showMapDetails.setMnemonic(KeyEvent.VK_D);
  showMapDetails.setSelected(TileImageFactory.getShowReliefImages());
  showMapDetails.addActionListener(
      e -> {
        if (TileImageFactory.getShowReliefImages() == showMapDetails.isSelected()) {
          return;
        }
        TileImageFactory.setShowReliefImages(showMapDetails.isSelected());
        new Thread(
                () -> frame.getMapPanel().updateCountries(gameData.getMap().getTerritories()),
                "Show map details thread")
            .start();
      });
  add(showMapDetails);
}
 
Example #7
Source File: Actions.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void init(JCheckBoxMenuItem item, boolean popup) {
    this.popup = popup;

    if (popup) {
        prepareMargins(item, action);
    }

    Object base = action.getValue("iconBase"); //NOI18N
    Object i = null;

    if (action instanceof SystemAction) {
        i = action.getValue(SystemAction.PROP_ICON);
    } else {
        i = action.getValue(Action.SMALL_ICON);
    }

    hasOwnIcon = (base != null) || (i != null);
}
 
Example #8
Source File: bug8031573.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void init() {
    try {

        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                JMenuBar bar = new JMenuBar();
                JMenu menu = new JMenu("Menu");
                JCheckBoxMenuItem checkBoxMenuItem
                        = new JCheckBoxMenuItem("JCheckBoxMenuItem");
                checkBoxMenuItem.setSelected(true);
                menu.add(checkBoxMenuItem);
                bar.add(menu);
                setJMenuBar(bar);
            }
        });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #9
Source File: bug8031573.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void init() {
    try {
        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                JMenuBar bar = new JMenuBar();
                JMenu menu = new JMenu("Menu");
                JCheckBoxMenuItem checkBoxMenuItem
                        = new JCheckBoxMenuItem("JCheckBoxMenuItem");
                checkBoxMenuItem.setSelected(true);
                menu.add(checkBoxMenuItem);
                bar.add(menu);
                setJMenuBar(bar);
            }
        });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #10
Source File: bug8031573.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void init() {
    try {
        SwingUtilities.invokeAndWait(new Runnable() {

            @Override
            public void run() {
                JMenuBar bar = new JMenuBar();
                JMenu menu = new JMenu("Menu");
                JCheckBoxMenuItem checkBoxMenuItem
                        = new JCheckBoxMenuItem("JCheckBoxMenuItem");
                checkBoxMenuItem.setSelected(true);
                menu.add(checkBoxMenuItem);
                bar.add(menu);
                setJMenuBar(bar);
            }
        });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #11
Source File: ButtonBuilders.java    From netbeans with Apache License 2.0 6 votes vote down vote up
static ComponentBuilder getBuilder(Instance instance, Heap heap) {
    if (DetailsUtils.isSubclassOf(instance, JButton.class.getName())) {
        return new JButtonBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JCheckBox.class.getName())) {
        return new JCheckBoxBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JRadioButton.class.getName())) {
        return new JRadioButtonBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JToggleButton.class.getName())) {
        return new JToggleButtonBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JCheckBoxMenuItem.class.getName())) {
        return new JCheckBoxMenuItemBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JRadioButtonMenuItem.class.getName())) {
        return new JRadioButtonMenuItemBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JMenu.class.getName())) {
        return new JMenuBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JMenuBar.class.getName())) {
        return new JMenuBarBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JMenuItem.class.getName())) {
        return new JMenuItemBuilder(instance, heap);
    }
    return null;
}
 
Example #12
Source File: InstancesListControllerUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void addMenuItemListener(final JCheckBoxMenuItem menuItem) {
    final boolean[] internalChange = new boolean[1];
    menuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {
            if (internalChange[0]) return;
            final int column = Integer.parseInt(e.getActionCommand());
            if (column == 3 && !instancesListTableModel.isRealColumnVisible(column)) {
                BrowserUtils.performTask(new Runnable() {
                    public void run() {
                        final int retainedSizesState = instancesListController.getInstancesController().
                                getHeapFragmentWalker().computeRetainedSizes(false, true);
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                if (retainedSizesState != HeapFragmentWalker.RETAINED_SIZES_COMPUTED) {
                                    internalChange[0] = true;
                                    menuItem.setSelected(!menuItem.isSelected());
                                    internalChange[0] = false;
                                } else {
                                    toggleColumnVisibility(column, true);
                                }
                            }
                        });
                    }
                });
            } else {
                toggleColumnVisibility(column, true);
            }

        }
    });
}
 
Example #13
Source File: GameMenu.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
private void addEditMode() {
  final JCheckBoxMenuItem editMode = new JCheckBoxMenuItem("Enable Edit Mode");
  editMode.setModel(frame.getEditModeButtonModel());
  final JMenuItem editMenuItem = add(editMode);
  editMenuItem.setMnemonic(KeyEvent.VK_E);
  editMenuItem.setAccelerator(
      KeyStroke.getKeyStroke(
          KeyEvent.VK_E, Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()));
}
 
Example #14
Source File: ViewMenu.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
private void addShowMapBlends() {
  showMapBlends = new JCheckBoxMenuItem("Show Map Blends");
  showMapBlends.setMnemonic(KeyEvent.VK_B);
  if (uiContext.getMapData().getHasRelief()
      && showMapDetails.isEnabled()
      && showMapDetails.isSelected()) {
    showMapBlends.setEnabled(true);
    showMapBlends.setSelected(TileImageFactory.getShowMapBlends());
  } else {
    showMapBlends.setSelected(false);
    showMapBlends.setEnabled(false);
  }
  showMapBlends.addActionListener(
      e -> {
        if (TileImageFactory.getShowMapBlends() == showMapBlends.isSelected()) {
          return;
        }
        TileImageFactory.setShowMapBlends(showMapBlends.isSelected());
        TileImageFactory.setShowMapBlendMode(uiContext.getMapData().getMapBlendMode());
        TileImageFactory.setShowMapBlendAlpha(uiContext.getMapData().getMapBlendAlpha());
        new Thread(
                () -> frame.getMapPanel().updateCountries(gameData.getMap().getTerritories()),
                "Show map Blends thread")
            .start();
      });
  add(showMapBlends);
}
 
Example #15
Source File: FieldsBrowserControllerUI.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private void addMenuItemListener(final JCheckBoxMenuItem menuItem) {
    final boolean[] internalChange = new boolean[1];
    menuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {
            if (internalChange[0]) return;
            final int column = Integer.parseInt(e.getActionCommand());
            if (column == 5 && !fieldsListTableModel.isRealColumnVisible(column)) {
                BrowserUtils.performTask(new Runnable() {
                    public void run() {
                        final int retainedSizesState = fieldsBrowserController.getInstancesControllerHandler().
                                getHeapFragmentWalker().computeRetainedSizes(false, true);
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                if (retainedSizesState != HeapFragmentWalker.RETAINED_SIZES_COMPUTED) {
                                    internalChange[0] = true;
                                    menuItem.setSelected(!menuItem.isSelected());
                                    internalChange[0] = false;
                                } else {
                                    fieldsListTableModel.setRealColumnVisibility(column,
                                            !fieldsListTableModel.isRealColumnVisible(column));
                                    fieldsListTable.createDefaultColumnsFromModel();
                                    fieldsListTable.updateTreeTableHeader();
                                    setColumnsData();
                                }
                            }
                        });
                    }
                });
            } else {
                fieldsListTableModel.setRealColumnVisibility(column,
                        !fieldsListTableModel.isRealColumnVisible(column));
                fieldsListTable.createDefaultColumnsFromModel();
                fieldsListTable.updateTreeTableHeader();
                setColumnsData();
            }
        }
    });
}
 
Example #16
Source File: MSMSLibrarySubmissionWindow.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
private void addMenu() {
  JMenuBar menu = new JMenuBar();
  JMenu settings = new JMenu("Settings");
  menu.add(settings);
  JFrame thisframe = this;

  // reset zoom
  JMenuItem resetZoom = new JMenuItem("reset zoom");
  menu.add(resetZoom);
  resetZoom.addActionListener(e -> {
    if (group != null)
      group.resetZoom();
  });

  // JMenuItem setSize = new JMenuItem("chart size");
  // menu.add(setSize);
  // setSize.addActionListener(e -> {
  // Dimension dim = SizeSelectDialog.getSizeInput();
  // if (dim != null)
  // setChartSize(dim);
  // });

  //
  addCheckBox(settings, "show legend", showLegend,
      e -> setShowLegend(((JCheckBoxMenuItem) e.getSource()).isSelected()));
  addCheckBox(settings, "show title", showTitle,
      e -> setShowTitle(((JCheckBoxMenuItem) e.getSource()).isSelected()));
  addCheckBox(settings, "show crosshair", showCrosshair,
      e -> setShowCrosshair(((JCheckBoxMenuItem) e.getSource()).isSelected()));;

  this.setJMenuBar(menu);
}
 
Example #17
Source File: InstancesListControllerUI.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private void addMenuItemListener(final JCheckBoxMenuItem menuItem) {
    final boolean[] internalChange = new boolean[1];
    menuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {
            if (internalChange[0]) return;
            final int column = Integer.parseInt(e.getActionCommand());
            if (column == 3 && !instancesListTableModel.isRealColumnVisible(column)) {
                BrowserUtils.performTask(new Runnable() {
                    public void run() {
                        final int retainedSizesState = instancesListController.getInstancesController().
                                getHeapFragmentWalker().computeRetainedSizes(false, true);
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                if (retainedSizesState != HeapFragmentWalker.RETAINED_SIZES_COMPUTED) {
                                    internalChange[0] = true;
                                    menuItem.setSelected(!menuItem.isSelected());
                                    internalChange[0] = false;
                                } else {
                                    toggleColumnVisibility(column, true);
                                }
                            }
                        });
                    }
                });
            } else {
                toggleColumnVisibility(column, true);
            }

        }
    });
}
 
Example #18
Source File: BoolSettingAction.java    From scelight with Apache License 2.0 5 votes vote down vote up
/**
 * Overrides {@link XAction#addToMenu(JMenu)} to add a {@link JCheckBoxMenuItem} instead of a {@link JMenuItem}.
 */
@Override
public JMenuItem addToMenu( final JMenu menu ) {
	final JCheckBoxMenuItem mi = new JCheckBoxMenuItem();
	
	menu.add( mi );
	mi.setAction( this );
	mi.setToolTipText( null ); // We don't want tool tip on menu items...
	
	return mi;
}
 
Example #19
Source File: TestKit.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void showStatusLabels() {
    JMenuBarOperator mbo = new JMenuBarOperator(MainWindowOperator.getDefault().getJMenuBar());
    JMenuItemOperator mo = mbo.showMenuItem("View|Show Versioning Labels");
    JCheckBoxMenuItemOperator cbmio = new JCheckBoxMenuItemOperator((JCheckBoxMenuItem) mo.getSource());
    if (!cbmio.getState())
        cbmio.doClick();
}
 
Example #20
Source File: bug6438430.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    JMenu subMenu1 = new JMenu("Long-titled Sub Menu");
    subMenu1.add(new JMenuItem("SubMenu Item"));
    JMenuItem checkBoxMenuItem1 = new JCheckBoxMenuItem("CheckBox");

    JMenu menu1 = new JMenu("It works always");
    menu1.add(checkBoxMenuItem1);
    menu1.add(subMenu1);

    // Simulate DefaultMenuLayout calls.
    // The latest traversed menu item must be the widest.
    checkBoxMenuItem1.getPreferredSize();
    int width1 = subMenu1.getPreferredSize().width;
    System.out.println("width1 = " + width1);


    JMenu subMenu2 = new JMenu("Long-titled Sub Menu");
    subMenu2.add(new JMenuItem("SubMenu Item"));
    JMenuItem checkBoxMenuItem2 = new JCheckBoxMenuItem("CheckBox");

    JMenu menu2 = new JMenu("It did not work before the fix");
    menu2.add(subMenu2);
    menu2.add(checkBoxMenuItem2);

    // Simulate DefaultMenuLayout calls.
    // The latest traversed menu item must be the widest.
    subMenu2.getPreferredSize();
    int width2 = checkBoxMenuItem2.getPreferredSize().width;
    System.out.println("width2 = " + width2);

    if (width1 != width2) {
        throw new RuntimeException( "Submenu title and submenu indicator " +
                                    "overlap on JMenuItem!" );
    }

    System.out.println("Test passed");
}
 
Example #21
Source File: VizPanel.java    From ontopia with Apache License 2.0 5 votes vote down vote up
/**
 * Creates search menu items.
 */
protected void createSearchMenuItems() {
  searchMenuItem = new JCheckBoxMenuItem(Messages
      .getString("Viz.ShowSearchBar"),
      searchPanelVisible);
  searchMenuItem.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent action) {
      switchSearchPanel();
      searchMenuItem.setSelected(searchPanelVisible);
    }
  });
  add(glPopup, searchMenuItem, ITEM_ID_SHOW_SEARCH_BAR);
}
 
Example #22
Source File: bug6438430.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    JMenu subMenu1 = new JMenu("Long-titled Sub Menu");
    subMenu1.add(new JMenuItem("SubMenu Item"));
    JMenuItem checkBoxMenuItem1 = new JCheckBoxMenuItem("CheckBox");

    JMenu menu1 = new JMenu("It works always");
    menu1.add(checkBoxMenuItem1);
    menu1.add(subMenu1);

    // Simulate DefaultMenuLayout calls.
    // The latest traversed menu item must be the widest.
    checkBoxMenuItem1.getPreferredSize();
    int width1 = subMenu1.getPreferredSize().width;
    System.out.println("width1 = " + width1);


    JMenu subMenu2 = new JMenu("Long-titled Sub Menu");
    subMenu2.add(new JMenuItem("SubMenu Item"));
    JMenuItem checkBoxMenuItem2 = new JCheckBoxMenuItem("CheckBox");

    JMenu menu2 = new JMenu("It did not work before the fix");
    menu2.add(subMenu2);
    menu2.add(checkBoxMenuItem2);

    // Simulate DefaultMenuLayout calls.
    // The latest traversed menu item must be the widest.
    subMenu2.getPreferredSize();
    int width2 = checkBoxMenuItem2.getPreferredSize().width;
    System.out.println("width2 = " + width2);

    if (width1 != width2) {
        throw new RuntimeException( "Submenu title and submenu indicator " +
                                    "overlap on JMenuItem!" );
    }

    System.out.println("Test passed");
}
 
Example #23
Source File: MenuEditLayer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private String getComponentDefaultsPrefix(JComponent c) {
    if(c instanceof JMenuBar) {
        return "MenuBar"; // NOI18N
    }
    if(c instanceof JMenu) {
        return "Menu"; // NOI18N
    }
    if(c instanceof JCheckBoxMenuItem) {
        return "CheckBoxMenuItem"; // NOI18N
    }
    if(c instanceof JRadioButtonMenuItem) {
        return "RadioButtonMenuItem"; // NOI18N
    }
    return "MenuItem"; // NOI18N
}
 
Example #24
Source File: TestKit.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void showStatusLabels() {
    JMenuBarOperator mbo = new JMenuBarOperator(MainWindowOperator.getDefault().getJMenuBar());
    JMenuItemOperator mo = mbo.showMenuItem("View|Show Versioning Labels");
    JCheckBoxMenuItemOperator cbmio = new JCheckBoxMenuItemOperator((JCheckBoxMenuItem) mo.getSource());
    if (!cbmio.getState()) {
        cbmio.doClick();
    }
}
 
Example #25
Source File: FilterSubmenuAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(ActionEvent ev) {
    Object source = ev.getSource();
    // react just on submenu items, not on submenu click itself
    if (source instanceof JCheckBoxMenuItem) {
        JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem)source;
        String filterName = (String)(menuItem.getClientProperty(PROP_FILTER_NAME));
        filters.setSelected(filterName, menuItem.isSelected());
    }
}
 
Example #26
Source File: SyncEditorWithViewsAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void createItems() {
    if (menuItems == null) {
        menuItems = new JCheckBoxMenuItem[1];
        menuItems[0] = new JCheckBoxMenuItem(this);
        menuItems[0].setIcon(null);
        Mnemonics.setLocalizedText(menuItems[0],
                NbBundle.getMessage(SyncEditorWithViewsAction.class,
                "CTL_SYNC_EDITOR_WITH_VIEWS"));
    }
}
 
Example #27
Source File: ShowEditorOnlyAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void createItems() {
    synchronized( this ) {
        if (menuItems == null) {
            menuItems = new JCheckBoxMenuItem[1];
            menuItems[0] = new JCheckBoxMenuItem(this);
            menuItems[0].setIcon(null);
            Mnemonics.setLocalizedText(menuItems[0], NbBundle.getMessage( ShowEditorOnlyAction.class, "CTL_ShowOnlyEditor"));
        }
    }
}
 
Example #28
Source File: ToggleFullScreenAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void createItems() {
    synchronized( this ) {
        if (menuItems == null) {
            menuItems = new JCheckBoxMenuItem[1];
            menuItems[0] = new JCheckBoxMenuItem(this);
            menuItems[0].setIcon(null);
            Mnemonics.setLocalizedText(menuItems[0], NbBundle.getMessage(ToggleFullScreenAction.class, "CTL_ToggleFullScreenAction"));
        }
    }
}
 
Example #29
Source File: DropdownButton.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private void addAction(JPopupMenu popup, Action action) {
    if (action == null) {
        popup.addSeparator();
    } else {
        Class cls = (Class)action.getValue(KEY_CLASS);
        if (Boolean.class.equals(cls)) {
            Boolean boolvalue = (Boolean)action.getValue(KEY_BOOLVALUE);
            JCheckBoxMenuItem item = new JCheckBoxMenuItem(action);
            item.setSelected(boolvalue);
            popup.add(item);
        } else {
            popup.add(action);
        }
    }
}
 
Example #30
Source File: PresenterEditorAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void updateSelectedInPresenters() {
    if (isCheckBox()) {
        boolean selected = isSelected();
        if (menuPresenter instanceof JCheckBoxMenuItem) {
            ((JCheckBoxMenuItem)menuPresenter).setSelected(selected);
        }
        if (popupPresenter instanceof JCheckBoxMenuItem) {
            ((JCheckBoxMenuItem)popupPresenter).setSelected(selected);
        }
    }
}