List of usage examples for javax.swing JCheckBoxMenuItem addItemListener
public void addItemListener(ItemListener l)
ItemListener
to the checkbox
. From source file:CheckBoxSample.java
public static void main(String args[]) { ActionListener aListener = new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); String newLabel;//from www . java 2 s .c o m Icon newIcon; if (selected) { newLabel = "Girl"; newIcon = girlIcon; } else { newLabel = "Boy"; newIcon = boyIcon; } aButton.setText(newLabel); aButton.setIcon(newIcon); } }; ItemListener iListener = new ItemListener() { public void itemStateChanged(ItemEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); int state = event.getStateChange(); String newLabel; Icon newIcon; if (state == ItemEvent.SELECTED) { newLabel = "Girl"; newIcon = girlIcon; } else { newLabel = "Boy"; newIcon = boyIcon; } aButton.setText(newLabel); aButton.setIcon(newIcon); } }; JFrame frame = new JFrame("CheckBox Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("Menu"); menu.setMnemonic(KeyEvent.VK_M); JCheckBoxMenuItem one = new JCheckBoxMenuItem(); menu.add(one); JCheckBoxMenuItem two = new JCheckBoxMenuItem("Boy"); menu.add(two); JCheckBoxMenuItem three = new JCheckBoxMenuItem(boyIcon); menu.add(three); JCheckBoxMenuItem four = new JCheckBoxMenuItem("Girl", true); menu.add(four); JCheckBoxMenuItem five = new JCheckBoxMenuItem("Boy", boyIcon); five.addItemListener(iListener); menu.add(five); Icon stateIcon = new DiamondAbstractButtonStateIcon(Color.black); UIManager.put("CheckBoxMenuItem.checkIcon", stateIcon); JCheckBoxMenuItem six = new JCheckBoxMenuItem("Girl", girlIcon, true); six.addActionListener(aListener); menu.add(six); bar.add(menu); frame.setJMenuBar(bar); frame.setSize(350, 250); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame("MenuSample Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); // File Menu, F - Mnemonic JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu);/* w ww.jav a2s. c o m*/ // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New", KeyEvent.VK_N); fileMenu.add(newMenuItem); JCheckBoxMenuItem caseMenuItem = new JCheckBoxMenuItem("Case Sensitive"); caseMenuItem.setMnemonic(KeyEvent.VK_C); fileMenu.add(caseMenuItem); ItemListener iListener = new ItemListener() { public void itemStateChanged(ItemEvent event) { Icon girlIcon = new ImageIcon("g.jpg"); Icon boyIcon = new ImageIcon("b.jpg"); AbstractButton aButton = (AbstractButton) event.getSource(); int state = event.getStateChange(); String newLabel; Icon newIcon; if (state == ItemEvent.SELECTED) { newLabel = "Girl"; newIcon = girlIcon; } else { newLabel = "Boy"; newIcon = boyIcon; } aButton.setText(newLabel); aButton.setIcon(newIcon); } }; caseMenuItem.addItemListener(iListener); frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); }
From source file:JCheckBoxMenuItemActionListener.java
public static void main(final String args[]) { JFrame frame = new JFrame("MenuSample Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); // File Menu, F - Mnemonic JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu);/*from w w w.j ava 2s.c om*/ // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New", KeyEvent.VK_N); fileMenu.add(newMenuItem); JCheckBoxMenuItem caseMenuItem = new JCheckBoxMenuItem("Case Sensitive"); caseMenuItem.setMnemonic(KeyEvent.VK_C); fileMenu.add(caseMenuItem); ItemListener iListener = new ItemListener() { public void itemStateChanged(ItemEvent event) { Icon girlIcon = new ImageIcon("girl-r.jpg"); Icon boyIcon = new ImageIcon("boy-r.jpg"); AbstractButton aButton = (AbstractButton) event.getSource(); int state = event.getStateChange(); String newLabel; Icon newIcon; if (state == ItemEvent.SELECTED) { newLabel = "Girl"; newIcon = girlIcon; } else { newLabel = "Boy"; newIcon = boyIcon; } aButton.setText(newLabel); aButton.setIcon(newIcon); } }; caseMenuItem.addItemListener(iListener); frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); }
From source file:com.choicemaker.cm.modelmaker.gui.utils.HistoChartPanel.java
public HistoChartPanel(final JFreeChart chart, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips, final ModelMaker modelMaker) { super(chart, properties, save, print, zoom, tooltips); this.modelMaker = modelMaker; // horizontal zoom doesn't work, by setting false we don't get bogus menu item // setHorizontalZoom(false); // setVerticalZoom(true); final JCheckBoxMenuItem logYScale = new JCheckBoxMenuItem( ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.test.logscale.y")); logYScale.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { CategoryPlot p = (CategoryPlot) chart.getPlot(); Axis oldAxis = p.getRangeAxis(); if (logYScale.isSelected()) { LogarithmicAxis yAxis = new LogarithmicAxis(ChoiceMakerCoreMessages.m .formatMessage("train.gui.modelmaker.panel.histogram.cm.numpairs")); yAxis.setStrictValuesFlag(false); p.setRangeAxis(yAxis);/* w w w . j a v a 2 s. c om*/ } else { p.setRangeAxis(new NumberAxis(ChoiceMakerCoreMessages.m .formatMessage("train.gui.modelmaker.panel.histogram.cm.numpairs"))); } oldAxis.setPlot(null); chartChanged(new ChartChangeEvent(this)); } }); JPopupMenu popup = getPopupMenu(); popup.addSeparator(); popup.add(logYScale); popup.addSeparator(); select = new JMenu("Select"); final JMenuItem all = new JMenuItem("All"); select.add(all); final JMenuItem cmDiffer = new JMenuItem("Human marked differ"); select.add(cmDiffer); final JMenuItem cmHold = new JMenuItem("Human marked hold"); select.add(cmHold); final JMenuItem cmMatch = new JMenuItem("Human marked match"); select.add(cmMatch); ActionListener l = new ActionListener() { public void actionPerformed(ActionEvent ev) { ListeningMarkedRecordPairFilter filter = modelMaker.getFilter(); filter.reset(); filter.setFromPercentage(rangeFrom); filter.setToPercentage(rangeTo); Object src = ev.getSource(); if (src != all) { boolean[] b = new boolean[Decision.NUM_DECISIONS]; if (src == cmDiffer) { b[Decision.DIFFER.toInt()] = true; } else if (src == cmHold) { b[Decision.HOLD.toInt()] = true; } else if (src == cmMatch) { b[Decision.MATCH.toInt()] = true; } filter.setHumanDecision(b); } modelMaker.filterMarkedRecordPairList(); } }; all.addActionListener(l); cmDiffer.addActionListener(l); cmHold.addActionListener(l); cmMatch.addActionListener(l); popup.add(select); addChartMouseListener(new ChartMouseListener() { public void chartMouseClicked(ChartMouseEvent evt) { ChartEntity e = evt.getEntity(); if (e instanceof CategoryItemEntity) { CategoryItemEntity c = (CategoryItemEntity) e; int cat = c.getCategoryIndex(); HistoCategoryDataset data = (HistoCategoryDataset) ((CategoryPlot) getChart().getPlot()) .getDataset(); int len = data.getColumnCount(); float step = 1f / len; rangeFrom = cat * step; rangeTo = rangeFrom + step; ListeningMarkedRecordPairFilter filter = modelMaker.getFilter(); filter.reset(); filter.setFromPercentage(rangeFrom); filter.setToPercentage(rangeTo); boolean[] b = new boolean[Decision.NUM_DECISIONS]; int series = c.getSeries(); if (data.isIncludeHolds() && series != 0) { if (series == 1) { series = 2; } else { series = 1; } } b[series] = true; filter.setHumanDecision(b); modelMaker.filterMarkedRecordPairList(); } } public void chartMouseMoved(ChartMouseEvent arg0) { } }); }
From source file:daylightchart.gui.DaylightChartGui.java
private void createOptionsMenu(final JMenuBar menuBar, final JToolBar toolBar) { final JMenu menu = new JMenu(Messages.getString("DaylightChartGui.Menu.Options")); //$NON-NLS-1$ menu.setMnemonic('O'); final GuiAction options = new OptionsAction(this); menu.add(options);/*w w w. j ava 2s . co m*/ final GuiAction chartOptions = new ChartOptionsAction(this); menu.add(chartOptions); final GuiAction resetAll = new ResetAllAction(this); menu.add(resetAll); menu.addSeparator(); final JCheckBoxMenuItem slimUiMenuItem = new JCheckBoxMenuItem( Messages.getString("DaylightChartGui.Menu.Options.SlimUi")); //$NON-NLS-1$ slimUiMenuItem.setState(isSlimUi()); slimUiMenuItem.addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent e) { final boolean slimUi = e.getStateChange() == ItemEvent.SELECTED; final Options options = UserPreferences.optionsFile().getData(); options.setSlimUi(slimUi); UserPreferences.optionsFile().save(options); ResetAllAction.restart(DaylightChartGui.this, slimUi); } }); menu.add(slimUiMenuItem); menuBar.add(menu); toolBar.add(options); toolBar.add(chartOptions); toolBar.addSeparator(); }
From source file:org.jax.maanova.fit.gui.ResidualPlotPanel.java
@SuppressWarnings("serial") private JMenuBar createMenu() { JMenuBar menuBar = new JMenuBar(); // the file menu JMenu fileMenu = new JMenu("File"); fileMenu.add(this.saveGraphImageAction); menuBar.add(fileMenu);//from ww w . j av a 2s .co m // the tools menu JMenu toolsMenu = new JMenu("Tools"); JMenuItem configureGraphItem = new JMenuItem("Configure Graph..."); configureGraphItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { ResidualPlotPanel.this.chartConfigurationDialog.setVisible(true); } }); toolsMenu.add(configureGraphItem); toolsMenu.addSeparator(); toolsMenu.add(new AbstractAction("Zoom Out") { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { ResidualPlotPanel.this.autoRangeChart(); } }); toolsMenu.addSeparator(); JCheckBoxMenuItem showTooltipCheckbox = new JCheckBoxMenuItem("Show Info Popup for Nearest Point"); showTooltipCheckbox.setSelected(true); this.showTooltip = true; showTooltipCheckbox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { ResidualPlotPanel.this.showTooltip = e.getStateChange() == ItemEvent.SELECTED; ResidualPlotPanel.this.clearProbePopup(); } }); toolsMenu.add(showTooltipCheckbox); menuBar.add(toolsMenu); // the help menu JMenu helpMenu = new JMenu("Help"); JMenuItem helpMenuItem = new JMenuItem("Help...", new ImageIcon(ResidualPlotAction.class.getResource("/images/action/help-16x16.png"))); helpMenuItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { Maanova.getInstance().showHelp("residual-plot", ResidualPlotPanel.this); } }); helpMenu.add(helpMenuItem); menuBar.add(helpMenu); return menuBar; }
From source file:org.jax.maanova.madata.gui.ArrayScatterPlotPanel.java
@SuppressWarnings("serial") private JMenuBar createMenu() { JMenuBar menuBar = new JMenuBar(); // the file menu JMenu fileMenu = new JMenu("File"); fileMenu.add(this.saveGraphImageAction); menuBar.add(fileMenu);//from w w w . jav a 2s . c o m // the tools menu JMenu toolsMenu = new JMenu("Tools"); JMenuItem configureGraphItem = new JMenuItem("Configure Graph..."); configureGraphItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { ArrayScatterPlotPanel.this.chartConfigurationDialog.setVisible(true); } }); toolsMenu.add(configureGraphItem); toolsMenu.addSeparator(); toolsMenu.add(new AbstractAction("Zoom Out") { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { ArrayScatterPlotPanel.this.autoRangeChart(); } }); JCheckBoxMenuItem showTooltipCheckbox = new JCheckBoxMenuItem("Show Info Popup for Nearest Point"); showTooltipCheckbox.setSelected(true); this.showTooltip = true; showTooltipCheckbox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { ArrayScatterPlotPanel.this.showTooltip = e.getStateChange() == ItemEvent.SELECTED; ArrayScatterPlotPanel.this.clearProbePopup(); } }); toolsMenu.add(showTooltipCheckbox); menuBar.add(toolsMenu); // the help menu JMenu helpMenu = new JMenu("Help"); JMenuItem helpMenuItem = new JMenuItem("Help..."); Icon helpIcon = new ImageIcon(ArrayScatterPlotPanel.class.getResource("/images/action/help-16x16.png")); helpMenuItem.setIcon(helpIcon); helpMenuItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { Maanova.getInstance().showHelp("array-scatter-plot", ArrayScatterPlotPanel.this); } }); helpMenu.add(helpMenuItem); menuBar.add(helpMenu); return menuBar; }
From source file:org.jax.maanova.test.gui.VolcanoPlotPanel.java
@SuppressWarnings("serial") private JMenuBar createMenu() { JMenuBar menuBar = new JMenuBar(); // the file menu JMenu fileMenu = new JMenu("File"); fileMenu.add(this.saveGraphImageAction); menuBar.add(fileMenu);// w w w .j av a 2 s . c om // the tools menu JMenu toolsMenu = new JMenu("Tools"); JMenuItem configureGraphItem = new JMenuItem("Configure Graph..."); configureGraphItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.chartConfigurationDialog.setVisible(true); } }); toolsMenu.add(configureGraphItem); toolsMenu.addSeparator(); toolsMenu.add(new AbstractAction("Clear Selections") { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.setSelectedIndices(new int[0]); } }); toolsMenu.addSeparator(); ButtonGroup dragButtonGroup = new ButtonGroup(); JCheckBoxMenuItem selectModeCheckBox = new JCheckBoxMenuItem("Drag Cursor to Select"); selectModeCheckBox.setSelected(true); this.dragToSelect = true; selectModeCheckBox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.dragToSelect = e.getStateChange() == ItemEvent.SELECTED; } }); dragButtonGroup.add(selectModeCheckBox); toolsMenu.add(selectModeCheckBox); JCheckBoxMenuItem zoomModeCheckBox = new JCheckBoxMenuItem("Drag Cursor to Zoom"); zoomModeCheckBox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.dragToZoom = e.getStateChange() == ItemEvent.SELECTED; } }); dragButtonGroup.add(zoomModeCheckBox); toolsMenu.add(zoomModeCheckBox); toolsMenu.addSeparator(); toolsMenu.add(new AbstractAction("Zoom Out") { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.autoRangeChart(); } }); toolsMenu.addSeparator(); JCheckBoxMenuItem showTooltipCheckbox = new JCheckBoxMenuItem("Show Info Popup for Nearest Point"); showTooltipCheckbox.setSelected(true); this.showTooltip = true; showTooltipCheckbox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.showTooltip = e.getStateChange() == ItemEvent.SELECTED; VolcanoPlotPanel.this.clearProbePopup(); } }); toolsMenu.add(showTooltipCheckbox); toolsMenu.addSeparator(); toolsMenu.add(this.displayTestResultsAction); toolsMenu.addSeparator(); toolsMenu.add(this.saveSelectedPointsMenuItem); JMenu selectPointsFromLisMenu = new JMenu("Select Points From Gene List"); List<String> geneListNames = this.maanovaTestResult.getParentExperiment().getGeneListNames(); if (geneListNames.isEmpty()) { JMenuItem noListsMenuItem = new JMenuItem("No Gene Lists Available"); noListsMenuItem.setEnabled(false); selectPointsFromLisMenu.add(noListsMenuItem); } else { for (final String geneListName : geneListNames) { JMenuItem currGeneListMenuItem = new JMenuItem( RUtilities.fromRIdentifierToReadableName(geneListName)); currGeneListMenuItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.selectedIndicesFromGeneList(geneListName); } }); selectPointsFromLisMenu.add(currGeneListMenuItem); } } toolsMenu.add(selectPointsFromLisMenu); menuBar.add(toolsMenu); // the help menu JMenu helpMenu = new JMenu("Help"); JMenuItem helpMenuItem = new JMenuItem("Help..."); Icon helpIcon = new ImageIcon(VolcanoPlotPanel.class.getResource("/images/action/help-16x16.png")); helpMenuItem.setIcon(helpIcon); helpMenuItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { Maanova.getInstance().showHelp("volcano-plot", VolcanoPlotPanel.this); } }); helpMenu.add(helpMenuItem); menuBar.add(helpMenu); return menuBar; }
From source file:jatoo.app.App.java
private JPopupMenu getWindowPopup(final Point location) { ///*w ww. j av a 2 s . c om*/ // hide final JMenuItem hideItem = new JMenuItem(getText("popup.hide")); hideItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { hide(); } }); // // send to back final JMenuItem sendToBackItem = new JMenuItem(getText("popup.send_to_back")); sendToBackItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { sendToBack(); } }); // // always on top final JCheckBoxMenuItem alwaysOnTopItem = new JCheckBoxMenuItem(getText("popup.always_on_top"), isAlwaysOnTop()); alwaysOnTopItem.addItemListener(new ItemListener() { public void itemStateChanged(final ItemEvent e) { setAlwaysOnTop(alwaysOnTopItem.isSelected()); } }); // // transparency final JSlider transparencySlider = new JSlider(JSlider.VERTICAL, 0, 100, getTransparency()); transparencySlider.setMajorTickSpacing(25); transparencySlider.setMinorTickSpacing(5); transparencySlider.setSnapToTicks(true); transparencySlider.setPaintTicks(true); transparencySlider.setPaintLabels(true); transparencySlider.addChangeListener(new ChangeListener() { public void stateChanged(final ChangeEvent e) { setTransparency(transparencySlider.getValue()); } }); final JMenu transparencyItem = new JMenu(getText("popup.transparency")); transparencyItem.add(transparencySlider); // // close final JMenuItem closeItem = new JMenuItem(getText("popup.close"), getIcon("close-016.png")); closeItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { System.exit(0); } }); // // the popup JPopupMenu popup = new JPopupMenu(getTitle()); popup.add(hideItem); popup.addSeparator(); popup.add(sendToBackItem); popup.add(alwaysOnTopItem); popup.add(transparencyItem); popup.addSeparator(); popup.add(closeItem); popup.setInvoker(popup); popup.setLocation(location); return popup; }
From source file:components.MenuDemo.java
public JMenuBar createMenuBar() { JMenuBar menuBar;/*w w w . j a v a2s .co m*/ JMenu menu, submenu; JMenuItem menuItem; JRadioButtonMenuItem rbMenuItem; JCheckBoxMenuItem cbMenuItem; //Create the menu bar. menuBar = new JMenuBar(); //Build the first menu. menu = new JMenu("A Menu"); menu.setMnemonic(KeyEvent.VK_A); menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items"); menuBar.add(menu); //a group of JMenuItems menuItem = new JMenuItem("A text-only menu item", KeyEvent.VK_T); //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything"); menuItem.addActionListener(this); menu.add(menuItem); ImageIcon icon = createImageIcon("images/middle.gif"); menuItem = new JMenuItem("Both text and icon", icon); menuItem.setMnemonic(KeyEvent.VK_B); menuItem.addActionListener(this); menu.add(menuItem); menuItem = new JMenuItem(icon); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(this); menu.add(menuItem); //a group of radio button menu items menu.addSeparator(); ButtonGroup group = new ButtonGroup(); rbMenuItem = new JRadioButtonMenuItem("A radio button menu item"); rbMenuItem.setSelected(true); rbMenuItem.setMnemonic(KeyEvent.VK_R); group.add(rbMenuItem); rbMenuItem.addActionListener(this); menu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem("Another one"); rbMenuItem.setMnemonic(KeyEvent.VK_O); group.add(rbMenuItem); rbMenuItem.addActionListener(this); menu.add(rbMenuItem); //a group of check box menu items menu.addSeparator(); cbMenuItem = new JCheckBoxMenuItem("A check box menu item"); cbMenuItem.setMnemonic(KeyEvent.VK_C); cbMenuItem.addItemListener(this); menu.add(cbMenuItem); cbMenuItem = new JCheckBoxMenuItem("Another one"); cbMenuItem.setMnemonic(KeyEvent.VK_H); cbMenuItem.addItemListener(this); menu.add(cbMenuItem); //a submenu menu.addSeparator(); submenu = new JMenu("A submenu"); submenu.setMnemonic(KeyEvent.VK_S); menuItem = new JMenuItem("An item in the submenu"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.ALT_MASK)); menuItem.addActionListener(this); submenu.add(menuItem); menuItem = new JMenuItem("Another item"); menuItem.addActionListener(this); submenu.add(menuItem); menu.add(submenu); //Build second menu in the menu bar. menu = new JMenu("Another Menu"); menu.setMnemonic(KeyEvent.VK_N); menu.getAccessibleContext().setAccessibleDescription("This menu does nothing"); menuBar.add(menu); return menuBar; }