Java Code Examples for javax.swing.JCheckBoxMenuItem#addItemListener()

The following examples show how to use javax.swing.JCheckBoxMenuItem#addItemListener() . 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: 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 2
Source File: ConfigureDataTableHeader.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * (Re-)creates the type menu with the selected type
 * @param selected the selected column Type
 */
private void updateTypeMenu(String selected) {
	typeMenu.removeAll();
	ButtonGroup typeGroup = new ButtonGroup();
	for (ColumnType columnType : ColumnType.values()) {
		String columnTypeName = DataImportWizardUtils.getNameForColumnType(columnType);
		JCheckBoxMenuItem checkboxItem = new JCheckBoxMenuItem(columnTypeName);
		if (columnTypeName.equals(selected)) {
			checkboxItem.setSelected(true);
		}
		checkboxItem.addItemListener(e -> {
			if (e.getStateChange() == ItemEvent.SELECTED) {
				changeType(columnType);
			}
		});
		typeGroup.add(checkboxItem);
		typeMenu.add(checkboxItem);
	}
}
 
Example 3
Source File: ActionFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JMenuItem getPopupMenuItem(JTextComponent target) {
    
    item = new JCheckBoxMenuItem(NbBundle.getBundle(BaseKit.class).
            getString("line-numbers-menuitem"), isLineNumbersVisible());
    item.addItemListener( new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            actionPerformed(null,null);
        }
    });
    return item;
}
 
Example 4
Source File: Desktop.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
JMenu makeStopOptionsMenu()
{
  return new JMenu(Strings.get("menu_stopOptions")) {
    private static final long serialVersionUID = 1L;

    {
      setToolTipText(Strings.get("menu_stopOptions.descr"));

      final ItemListener itemListener = new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e)
        {
          updateNameOfActionStopBundles();
        }
      };

      itemStopOptionsTransient =
        new JCheckBoxMenuItem(Strings.get("stop_option_transient"), false);
      itemStopOptionsTransient.setToolTipText(Strings
          .get("stop_option_transient.descr"));
      itemStopOptionsTransient.addItemListener(itemListener);

      add(itemStopOptionsTransient);
      updateNameOfActionStopBundles();
    }
  };
}
 
Example 5
Source File: Desktop.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
JMenu makeStartOptionsMenu()
{
  return new JMenu(Strings.get("menu_startOptions")) {
    private static final long serialVersionUID = 1L;

    {
      setToolTipText(Strings.get("menu_startOptions.descr"));

      final ItemListener itemListener = new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e)
        {
          updateNameOfActionStartBundles();
        }
      };

      itemStartOptionsTransient =
        new JCheckBoxMenuItem(Strings.get("start_option_transient"), false);
      itemStartOptionsTransient.setToolTipText(Strings
          .get("start_option_transient.descr"));
      itemStartOptionsTransient.addItemListener(itemListener);

      itemStartOptionsPolicy =
        new JCheckBoxMenuItem(Strings.get("start_option_policy"), true);
      itemStartOptionsPolicy.setToolTipText(Strings
          .get("start_option_policy.descr"));
      itemStartOptionsPolicy.addItemListener(itemListener);

      add(itemStartOptionsTransient);
      add(itemStartOptionsPolicy);
      updateNameOfActionStartBundles();
    }
  };
}
 
Example 6
Source File: MultiMSMSWindow.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
private void addCheckBox(JMenu menu, String title, boolean state, ItemListener il) {
  JCheckBoxMenuItem item = new JCheckBoxMenuItem(title);
  item.setSelected(state);
  item.addItemListener(il);
  menu.add(item);
}
 
Example 7
Source File: MSMSLibrarySubmissionWindow.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
private void addCheckBox(JMenu menu, String title, boolean state, ItemListener il) {
  JCheckBoxMenuItem item = new JCheckBoxMenuItem(title);
  item.setSelected(state);
  item.addItemListener(il);
  menu.add(item);
}
 
Example 8
Source File: MSMSLibrarySubmissionWindow.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
private void addCheckBox(JMenu menu, String title, boolean state, ItemListener il) {
  JCheckBoxMenuItem item = new JCheckBoxMenuItem(title);
  item.setSelected(state);
  item.addItemListener(il);
  menu.add(item);
}
 
Example 9
Source File: SpectraIdentificationResultsWindow.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
public SpectraIdentificationResultsWindow() {
  setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  setSize(new Dimension(1400, 900));
  getContentPane().setLayout(new BorderLayout());
  setTitle("Processing...");

  pnGrid = new JPanel();
  // any number of rows
  pnGrid.setLayout(new GridLayout(0, 1, 0, 0));

  pnGrid.setBackground(Color.WHITE);
  pnGrid.setAutoscrolls(false);

  noMatchesFound = new JLabel("I'm working on it", SwingConstants.CENTER);
  noMatchesFound.setFont(headerFont);
  // yellow
  noMatchesFound.setForeground(new Color(0xFFCC00));
  pnGrid.add(noMatchesFound, BorderLayout.CENTER);

  // Add the Windows menu
  JMenuBar menuBar = new JMenuBar();
  menuBar.add(new WindowsMenu());

  // set font size of chart
  JMenuItem btnSetup = new JMenuItem("Setup dialog");
  btnSetup.addActionListener(e -> {
    if (MZmineCore.getConfiguration()
        .getModuleParameters(SpectraIdentificationResultsModule.class)
        .showSetupDialog(this, true) == ExitCode.OK) {
      showExportButtonsChanged();
    }
  });
  menuBar.add(btnSetup);

  JCheckBoxMenuItem cbCoupleZoomY = new JCheckBoxMenuItem("Couple y-zoom");
  cbCoupleZoomY.setSelected(true);
  cbCoupleZoomY.addItemListener(e -> setCoupleZoomY(cbCoupleZoomY.isSelected()));
  menuBar.add(cbCoupleZoomY);

  JMenuItem btnSetFont = new JMenuItem("Set chart font");
  btnSetFont.addActionListener(e -> setChartFont());
  menuBar.add(btnSetFont);

  setJMenuBar(menuBar);

  scrollPane = new JScrollPane(pnGrid);
  getContentPane().add(scrollPane, BorderLayout.CENTER);
  scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
  scrollPane.setViewportView(pnGrid);

  totalMatches = new ArrayList<>();
  matchPanels = new HashMap<>();
  setCoupleZoomY(true);

  setVisible(true);
  setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  validate();
  repaint();
}
 
Example 10
Source File: MultiMSMSWindow.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
private void addCheckBox(JMenu menu, String title, boolean state, ItemListener il) {
  JCheckBoxMenuItem item = new JCheckBoxMenuItem(title);
  item.setSelected(state);
  item.addItemListener(il);
  menu.add(item);
}