List of usage examples for javax.swing JCheckBoxMenuItem isSelected
public boolean isSelected()
From source file:uk.co.petertribble.jkstat.gui.KstatBaseChartFrame.java
public void actionPerformed(ActionEvent e) { if (e.getSource() == exitItem) { kbc.stopLoop();/*from w ww .j a v a2s. co m*/ setVisible(false); dispose(); } else if (e.getSource() == saveItem) { saveImage(); } else if (e.getSource() == sleepItem1) { setDelay(1); } else if (e.getSource() == sleepItem2) { setDelay(2); } else if (e.getSource() == sleepItem5) { setDelay(5); } else if (e.getSource() == sleepItem10) { setDelay(10); } else if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem jmi = (JCheckBoxMenuItem) e.getSource(); String stat = jmi.getText(); if (jmi.isSelected()) { kbc.addStatistic(stat); } else { kbc.removeStatistic(stat); } } }
From source file:org.esa.beam.visat.toolviews.stat.MaskSelectionToolSupport.java
public JCheckBoxMenuItem createMaskSelectionModeMenuItem() { final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(String.format("Select Mask '%s'", maskName)); menuItem.setName("maskSelectionMode"); menuItem.addActionListener(new ActionListener() { @Override//from w ww. j a v a2 s .co m public void actionPerformed(ActionEvent e) { if (menuItem.isSelected()) { if (plotAreaSelectionTool == null) { plotAreaSelectionTool = new PlotAreaSelectionTool(chartPanel, MaskSelectionToolSupport.this); plotAreaSelectionTool.setAreaType(areaType); plotAreaSelectionTool.setFillPaint(createAlphaColor(maskColor, 50)); } plotAreaSelectionTool.install(); } else { if (plotAreaSelectionTool != null) { plotAreaSelectionTool.uninstall(); } } } }); return menuItem; }
From source file:InternalFrameTest.java
public DesktopFrame() { setTitle("InternalFrameTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); desktop = new JDesktopPane(); add(desktop, BorderLayout.CENTER); // set up menus JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar);/* www. j av a 2 s . c om*/ JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); JMenuItem openItem = new JMenuItem("New"); openItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { createInternalFrame(new JLabel(new ImageIcon(planets[counter] + ".gif")), planets[counter]); counter = (counter + 1) % planets.length; } }); fileMenu.add(openItem); JMenuItem exitItem = new JMenuItem("Exit"); exitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0); } }); fileMenu.add(exitItem); JMenu windowMenu = new JMenu("Window"); menuBar.add(windowMenu); JMenuItem nextItem = new JMenuItem("Next"); nextItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { selectNextWindow(); } }); windowMenu.add(nextItem); JMenuItem cascadeItem = new JMenuItem("Cascade"); cascadeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { cascadeWindows(); } }); windowMenu.add(cascadeItem); JMenuItem tileItem = new JMenuItem("Tile"); tileItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { tileWindows(); } }); windowMenu.add(tileItem); final JCheckBoxMenuItem dragOutlineItem = new JCheckBoxMenuItem("Drag Outline"); dragOutlineItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { desktop.setDragMode(dragOutlineItem.isSelected() ? JDesktopPane.OUTLINE_DRAG_MODE : JDesktopPane.LIVE_DRAG_MODE); } }); windowMenu.add(dragOutlineItem); }
From source file:de.hstsoft.sdeep.view.MainWindow.java
private void createUI() { mapView = new MapView(); getContentPane().add(mapView, BorderLayout.CENTER); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar);/*w w w . ja v a 2 s . c om*/ JMenu mnFile = new JMenu("File"); menuBar.add(mnFile); JMenuItem mntmOpenSaveGame = new JMenuItem("Open Savegame"); mntmOpenSaveGame.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { openFileChooser(); } }); mnFile.add(mntmOpenSaveGame); mnFile.addSeparator(); JMenuItem mntmExit = new JMenuItem("Exit"); mntmExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); mnFile.add(mntmExit); JMenu mnView = new JMenu("View"); menuBar.add(mnView); final JCheckBoxMenuItem menuItemShowinfo = new JCheckBoxMenuItem("ShowInfo"); menuItemShowinfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean showInfo = menuItemShowinfo.isSelected(); mapView.setShowInfo(showInfo); } }); menuItemShowinfo.setSelected(mapView.isShowInfo()); mnView.add(menuItemShowinfo); final JCheckBoxMenuItem menuItemShowgrid = new JCheckBoxMenuItem("ShowGrid"); menuItemShowgrid.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean showGrid = menuItemShowgrid.isSelected(); mapView.setShowGrid(showGrid); } }); menuItemShowgrid.setSelected(mapView.isShowGrid()); mnView.add(menuItemShowgrid); final JCheckBoxMenuItem menuItemNotes = new JCheckBoxMenuItem("ShowNotes"); menuItemNotes.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean showNotes = menuItemNotes.isSelected(); mapView.setShowNotes(showNotes); } }); menuItemNotes.setSelected(mapView.isShowNotes()); mnView.add(menuItemNotes); final JCheckBoxMenuItem menuItemAnimals = new JCheckBoxMenuItem("ShowAnimals"); menuItemAnimals.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean showAnimals = menuItemAnimals.isSelected(); mapView.setShowAnimals(showAnimals); } }); menuItemAnimals.setSelected(mapView.isShowAnimals()); mnView.add(menuItemAnimals); mnView.addSeparator(); menuItemFileWatcher = new JCheckBoxMenuItem("Auto refresh"); menuItemFileWatcher.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean enabled = menuItemFileWatcher.isSelected(); toggleAutoRefresh(enabled); } }); mnView.add(menuItemFileWatcher); mnView.addSeparator(); JMenuItem menuItemResetView = new JMenuItem("Reset view"); menuItemResetView.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { mapView.resetView(); } }); mnView.add(menuItemResetView); JMenu mnInfo = new JMenu("Info"); menuBar.add(mnInfo); JMenuItem mntmInfo = new JMenuItem("About"); mntmInfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showInfo(); } }); mnInfo.add(mntmInfo); }
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static JCheckBoxMenuItem getIntelCheckBoxMenuItem(String text) { final JCheckBoxMenuItem box = new JCheckBoxMenuItem(text, UIImages.EMPTY_BOX_ICON.getImageIcon()); // should do it through L&F, but couldn't find the way to do it // so we are using action listener to dynamically change icon box.addActionListener(new ActionListener() { @Override/* www .j av a 2 s . c o m*/ public void actionPerformed(ActionEvent e) { box.setIcon(box.isSelected() ? UIImages.CHECK_BOX_ICON.getImageIcon() : UIImages.EMPTY_BOX_ICON.getImageIcon()); } }); return box; }
From source file:de.tud.kom.p2psim.impl.skynet.visualization.SkyNetVisualization.java
public void actionPerformed(ActionEvent arg0) { String name = arg0.getActionCommand(); if (arg0.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) arg0.getSource(); if (j.isSelected()) { createPlotInWindow(name);/*from w w w . ja va 2 s . co m*/ } else { deletePlotInWindow(name); } } else { if (name.contains("Average Metrics")) { if (name.startsWith("Display")) { displayAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(0)); } else { removeAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(0)); } } else if (name.contains("General Metrics")) { if (name.startsWith("Display")) { displayAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(1)); } else { removeAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(1)); } } else if (name.contains("Metrics for Receiving")) { if (name.startsWith("Display")) { displayAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(2)); } else { removeAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(2)); } } else if (name.contains("Metrics for Sending")) { if (name.startsWith("Display")) { displayAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(3)); } else { removeAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(3)); } } else { for (int i = 0; i < mb.getMenu(1).getMenuComponentCount(); i++) { if (mb.getMenu(1).getMenuComponent(i) instanceof JMenu) { if (name.startsWith("Display")) { displayAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(i)); } else { removeAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(i)); } } } } } validate(); repaint(); Runtime.getRuntime().gc(); }
From source file:org.peerfact.impl.service.aggregation.skyeye.visualization.SkyNetVisualization.java
@Override public void actionPerformed(ActionEvent arg0) { String name = arg0.getActionCommand(); if (arg0.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) arg0.getSource(); if (j.isSelected()) { createPlotInWindow(name);//from w w w .ja v a2 s. c o m } else { deletePlotInWindow(name); } } else { if (name.contains("Average Metrics")) { if (name.startsWith("Display")) { displayAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(0)); } else { removeAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(0)); } } else if (name.contains("General Metrics")) { if (name.startsWith("Display")) { displayAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(1)); } else { removeAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(1)); } } else if (name.contains("Metrics for Receiving")) { if (name.startsWith("Display")) { displayAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(2)); } else { removeAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(2)); } } else if (name.contains("Metrics for Sending")) { if (name.startsWith("Display")) { displayAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(3)); } else { removeAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(3)); } } else { for (int i = 0; i < mb.getMenu(1).getMenuComponentCount(); i++) { if (mb.getMenu(1).getMenuComponent(i) instanceof JMenu) { if (name.startsWith("Display")) { displayAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(i)); } else { removeAllMetricsOfAGroup((JMenu) mb.getMenu(1).getMenuComponent(i)); } } } } } validate(); repaint(); // Runtime.getRuntime().gc(); }
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);//from w ww. j a v a 2 s . c o m } 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:de.tud.kom.p2psim.impl.skynet.visualization.SkyNetVisualization.java
private void removeAllMetricsOfAGroup(JMenu menu) { JCheckBoxMenuItem item = null; String name = null;//from ww w . j a v a 2s .co m for (int i = 0; i < menu.getMenuComponentCount(); i++) { if (menu.getMenuComponent(i) instanceof JCheckBoxMenuItem) { item = (JCheckBoxMenuItem) menu.getMenuComponent(i); name = item.getActionCommand(); if (item.isSelected()) { item.setSelected(false); deletePlotInWindow(name); } } } }
From source file:de.tud.kom.p2psim.impl.skynet.visualization.SkyNetVisualization.java
private void displayAllMetricsOfAGroup(JMenu menu) { JCheckBoxMenuItem item = null; String name = null;//from ww w. j a v a 2 s. c o m for (int i = 0; i < menu.getMenuComponentCount(); i++) { if (menu.getMenuComponent(i) instanceof JCheckBoxMenuItem) { item = (JCheckBoxMenuItem) menu.getMenuComponent(i); name = item.getActionCommand(); if (!item.isSelected()) { item.setSelected(true); createPlotInWindow(name); } } } }