List of usage examples for javax.swing JCheckBoxMenuItem JCheckBoxMenuItem
public JCheckBoxMenuItem(String text, boolean b)
From source file:org.rdv.viz.image.ImageViz.java
private void initPopupMenu() { final JPopupMenu popupMenu = new JPopupMenu(); // create a popup to copy an image to the clipboard final JMenuItem copyImageMenuItem = new JMenuItem("Copy"); copyImageMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { copyImage();/* w ww . j av a2 s. co m*/ } }); popupMenu.add(copyImageMenuItem); popupMenu.addSeparator(); // create a popup to save an image final JMenuItem saveImageMenuItem = new JMenuItem("Save as..."); saveImageMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { saveImage(); } }); popupMenu.add(saveImageMenuItem); popupMenu.addSeparator(); // create a popup to copy an image to the clipboard final JMenuItem printImageMenuItem = new JMenuItem("Print..."); printImageMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { printImage(); } }); popupMenu.add(printImageMenuItem); popupMenu.addSeparator(); final JMenuItem zoomInMenuItem = new JMenuItem("Zoom in"); zoomInMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { imagePanel.zoomIn(); } }); popupMenu.add(zoomInMenuItem); final JMenuItem zoomOutMenuItem = new JMenuItem("Zoom out"); zoomOutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { imagePanel.zoomOut(); } }); popupMenu.add(zoomOutMenuItem); final JSeparator zoomMenuSeparator = new JPopupMenu.Separator(); popupMenu.add(zoomMenuSeparator); autoScaleMenuItem = new JCheckBoxMenuItem("Auto scale", true); autoScaleMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { setAutoScale(autoScaleMenuItem.isSelected()); } }); popupMenu.add(autoScaleMenuItem); final JMenuItem resetScaleMenuItem = new JMenuItem("Reset scale"); resetScaleMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { imagePanel.setScale(1); } }); popupMenu.add(resetScaleMenuItem); showNavigationImageMenuItem = new JCheckBoxMenuItem("Show navigation image", imagePanel.isNavigationImageEnabled()); showNavigationImageMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { setShowNavigationImage(showNavigationImageMenuItem.isSelected()); } }); popupMenu.add(showNavigationImageMenuItem); final JMenu maximumFilmstripImagesMenu = new JMenu("Maximum number of images"); maximumFilmstripImagesButtonGroup = new ButtonGroup(); for (final int maximumFilmstripImagesValue : MAXIMUM_FILMSTRIP_IMAGES_VALUES) { boolean selected = filmstripPanel.getMaximumImages() == maximumFilmstripImagesValue; JMenuItem maximumFilmStripImagesMenuItem = new JRadioButtonMenuItem( Integer.toString(maximumFilmstripImagesValue), selected); maximumFilmStripImagesMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { filmstripPanel.setMaximumImages(maximumFilmstripImagesValue); } }); maximumFilmstripImagesButtonGroup.add(maximumFilmStripImagesMenuItem); maximumFilmstripImagesMenu.add(maximumFilmStripImagesMenuItem); } popupMenu.add(maximumFilmstripImagesMenu); popupMenu.addSeparator(); final JCheckBoxMenuItem showAsFilmstripMenuItem = new JCheckBoxMenuItem("Show as filmstrip", filmstripMode); showAsFilmstripMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { boolean filmstripMode = showAsFilmstripMenuItem.isSelected(); setFilmstripMode(filmstripMode); } }); popupMenu.add(showAsFilmstripMenuItem); final JCheckBoxMenuItem useThumbnailImageMenuItem = new JCheckBoxMenuItem("Use thumbnail image", useThumbnailImage); useThumbnailImageMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setUseThumbnailImage(useThumbnailImageMenuItem.isSelected()); } }); popupMenu.add(useThumbnailImageMenuItem); hideRoboticControlsMenuItem = new JCheckBoxMenuItem("Disable robotic controls", false); hideRoboticControlsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { setRoboticControls(); } }); popupMenu.add(hideRoboticControlsMenuItem); // enable the save image popup if an image is being displayed popupMenu.addPopupMenuListener(new PopupMenuListener() { public void popupMenuWillBecomeVisible(PopupMenuEvent arg0) { boolean hasImage = displayedImageData != null; saveImageMenuItem.setEnabled(hasImage); copyImageMenuItem.setEnabled(hasImage); printImageMenuItem.setEnabled(hasImage); boolean enableZoom = hasImage && !filmstripMode; zoomInMenuItem.setEnabled(enableZoom); zoomInMenuItem.setVisible(!filmstripMode); zoomOutMenuItem.setEnabled(enableZoom); zoomOutMenuItem.setVisible(!filmstripMode); zoomMenuSeparator.setVisible(!filmstripMode); autoScaleMenuItem.setVisible(!filmstripMode); resetScaleMenuItem.setVisible(!filmstripMode); showNavigationImageMenuItem.setVisible(!filmstripMode); maximumFilmstripImagesMenu.setVisible(filmstripMode); showAsFilmstripMenuItem.setSelected(filmstripMode); useThumbnailImageMenuItem.setSelected(useThumbnailImage); useThumbnailImageMenuItem.setVisible(imageHasThumbnail()); hideRoboticControlsMenuItem.setVisible(flexTPSStream != null); } public void popupMenuWillBecomeInvisible(PopupMenuEvent arg0) { } public void popupMenuCanceled(PopupMenuEvent arg0) { } }); // set component popup and mouselistener to trigger it panel.setComponentPopupMenu(popupMenu); imagePanel.setComponentPopupMenu(popupMenu); filmstripPanel.setComponentPopupMenu(popupMenu); panel.addMouseListener(new MouseInputAdapter() { }); }
From source file:org.rdv.viz.spectrum.SpectrumViz.java
/** * Initializes the popup menu. This takes the popup menu from the chart and * adds on to it./*from w ww . ja v a2 s . c o m*/ */ private void initPopupMenu() { JPopupMenu popupMenu = spectrumAnalyzerPanel.getPopupMenu(); JMenuItem propertiesMenuItem = (JMenuItem) popupMenu.getComponent(0); propertiesMenuItem.setText("Chart Properties..."); popupMenu.add(new JPopupMenu.Separator()); showPropertiesMenuItem = new JCheckBoxMenuItem("Show properties", true); showPropertiesMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setPropertiesVisible(showPropertiesMenuItem.isSelected()); } }); popupMenu.add(showPropertiesMenuItem); panel.setComponentPopupMenu(popupMenu); }
From source file:org.sikuli.ide.SikuliIDE.java
private void initViewMenu() throws NoSuchMethodException { int scMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); _viewMenu.setMnemonic(java.awt.event.KeyEvent.VK_V); if (prefs.getPrefMoreCommandBar()) { chkShowCmdList = new JCheckBoxMenuItem(_I("menuViewCommandList"), true); _viewMenu.add(/*from www. j av a 2 s . co m*/ createMenuItem(chkShowCmdList, KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, scMask), new ViewAction(ViewAction.CMD_LIST))); } chkShowThumbs = new JCheckBoxMenuItem(_I("menuViewShowThumbs"), false); _viewMenu.add(createMenuItem(chkShowThumbs, KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, scMask), new ViewAction(ViewAction.SHOW_THUMBS))); //TODO Message Area clear //TODO Message Area LineBreak }
From source file:pl.otros.logview.gui.LogViewPanel.java
private void addMessageFormatterOrColorizerToMenu(final JPopupMenu menu, final PluginableElement pluginable, final PluginableElementsContainer selectedPluginableContainer) { {/* w w w . j av a 2 s . c o m*/ final JCheckBoxMenuItem boxMenuItem = new JCheckBoxMenuItem(pluginable.getName(), selectedPluginableContainer.contains(pluginable)); boxMenuItem.setToolTipText(pluginable.getDescription()); menu.add(boxMenuItem); boxMenuItem.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (boxMenuItem.isSelected() && !selectedPluginableContainer.contains(pluginable)) { selectedPluginableContainer.addElement(pluginable); } else if (!boxMenuItem.isSelected() && selectedPluginableContainer.contains(pluginable)) { selectedPluginableContainer.removeElement(pluginable); } } }); } }
From source file:processing.app.Editor.java
protected void populatePortMenu() { serialMenu.removeAll();/*from w w w. jav a 2 s . co m*/ String selectedPort = PreferencesData.get("serial.port"); List<BoardPort> ports = Base.getDiscoveryManager().discovery(); ports = platform.filterPorts(ports, PreferencesData.getBoolean("serial.ports.showall")); Collections.sort(ports, new Comparator<BoardPort>() { @Override public int compare(BoardPort o1, BoardPort o2) { return BOARD_PROTOCOLS_ORDER.indexOf(o1.getProtocol()) - BOARD_PROTOCOLS_ORDER.indexOf(o2.getProtocol()); } }); String lastProtocol = null; String lastProtocolTranslated; for (BoardPort port : ports) { if (lastProtocol == null || !port.getProtocol().equals(lastProtocol)) { if (lastProtocol != null) { serialMenu.addSeparator(); } lastProtocol = port.getProtocol(); if (BOARD_PROTOCOLS_ORDER.indexOf(port.getProtocol()) != -1) { lastProtocolTranslated = BOARD_PROTOCOLS_ORDER_TRANSLATIONS .get(BOARD_PROTOCOLS_ORDER.indexOf(port.getProtocol())); } else { lastProtocolTranslated = port.getProtocol(); } JMenuItem lastProtocolMenuItem = new JMenuItem(_(lastProtocolTranslated)); lastProtocolMenuItem.setEnabled(false); serialMenu.add(lastProtocolMenuItem); } String address = port.getAddress(); String label = port.getLabel(); JCheckBoxMenuItem item = new JCheckBoxMenuItem(label, address.equals(selectedPort)); item.addActionListener(new SerialMenuListener(address)); serialMenu.add(item); } serialMenu.setEnabled(serialMenu.getMenuComponentCount() > 0); }
From source file:psidev.psi.mi.tab.client.gui.DragAndDropConverter.java
public static void addFileMenu(final JFrame frame, JMenuBar menuBar) { // Create a menu JMenu menu = new JMenu("File"); menuBar.add(menu);/*from w w w . ja v a2s . c om*/ // Create a file open iten JMenuItem openFileItem = new JMenuItem("Open files..."); openFileItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setApproveButtonText("Convert to MITAB25"); // Enable multiple selections chooser.setMultiSelectionEnabled(true); // Show the dialog; wait until dialog is closed chooser.showOpenDialog(frame); // Retrieve the selected files. This method returns empty // if multiple-selection mode is not enabled. File[] files = chooser.getSelectedFiles(); if (files != null && files.length > 0) { FilesProcessor processor = new FilesProcessor(); processor.process(frame, files, expansionStrategy, postProcessorStrategy, aggregateSelectedFiles); } } }); menu.add(openFileItem); // Create an exit final JMenuItem mergeItem = new JCheckBoxMenuItem("Aggregate all selected files", aggregateSelectedFiles); mergeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // If selected, all files dropped or selected at once are aggregated into a single MITAB file aggregateSelectedFiles = mergeItem.isSelected(); log.debug("Aggregate is " + aggregateSelectedFiles); } }); menu.add(mergeItem); // Create an exit JMenuItem exitItem = new JMenuItem("Exit"); exitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); menu.add(exitItem); }