List of usage examples for javax.swing JMenu setVisible
@BeanProperty(hidden = true, visualUpdate = true) public void setVisible(boolean aFlag)
From source file:at.becast.youploader.gui.FrmMain.java
public void initMenuBar() { JMenuBar mnuBar = new JMenuBar(); JMenu mnuFile = new JMenu(); JMenuItem mnuQuit = new JMenuItem(); mnuAcc = new JMenu(); mnuFile.setText(LANG.getString("frmMain.menu.File")); mnuQuit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK)); mnuQuit.setText(LANG.getString("frmMain.menu.Quit")); mnuQuit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { mnuQuitActionPerformed();/*from www. j a v a 2 s . co m*/ } }); mnuFile.add(mnuQuit); mnuBar.add(mnuFile); mnuAcc.setText(LANG.getString("frmMain.menu.Account")); mnuBar.add(mnuAcc); JSeparator separator = new JSeparator(); JMenuItem mntmAddAccount = new JMenuItem(LANG.getString("frmMain.menu.AddAccount")); mntmAddAccount.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { mntmAddAccountActionPerformed(); } }); mnuAcc.add(mntmAddAccount); mnuAcc.add(separator); JMenu mnLanguage = new JMenu("Language"); mnLanguage.setVisible(false); mnLanguage.setEnabled(false); mnuBar.add(mnLanguage); JMenu menu = new JMenu("?"); mnuBar.add(menu); JMenuItem mntmDonate = new JMenuItem(LANG.getString("frmMain.menu.Donate")); menu.add(mntmDonate); mntmDonate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { donateButton(); } }); JMenuItem mntmAbout = new JMenuItem(LANG.getString("frmMain.menu.About")); mntmAbout.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { FrmAbout about = new FrmAbout(); about.setVisible(true); } }); menu.add(mntmAbout); JMenuItem mntmShowLogfile = new JMenuItem(LANG.getString("frmMain.menu.ShowLogfile")); mntmShowLogfile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { DesktopUtil.openDir(new File(System.getProperty("user.home") + "/YouPloader")); } }); menu.add(mntmShowLogfile); JMenuItem mntmUploadLogfile = new JMenuItem(LANG.getString("frmMain.menu.UploadLatestLogfile")); mntmUploadLogfile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { DesktopUtil.openDir(new File(System.getProperty("user.home") + "/YouPloader")); } }); menu.add(mntmUploadLogfile); chckbxmntmCheckForUpdates = new JCheckBoxMenuItem(LANG.getString("frmMain.menu.CheckforUpdates")); menu.add(chckbxmntmCheckForUpdates); if (Main.s.setting.get("notify_updates").equals("1")) { chckbxmntmCheckForUpdates.setSelected(true); } chckbxmntmCheckForUpdates.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { toggleUpdateNotifier(); } }); setJMenuBar(mnuBar); }
From source file:edu.ku.brc.specify.tools.l10nios.StrLocalizerAppForiOS.java
/** * @param frame//from w ww . ja v a 2 s . c om */ public void addMenuBar(final JFrame frame) { this.frame = frame; JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu(getResourceString("FILE")); JMenuItem chooseFileItem = new JMenuItem(getResourceString("StrLocalizerApp.ChooseFileMenu")); fileMenu.add(chooseFileItem); chooseFileItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doChooseFile(); } }); JMenuItem saveItem = new JMenuItem(getResourceString("SAVE")); fileMenu.add(saveItem); saveItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doSave(); } }); if (!UIHelper.isMacOS()) { fileMenu.addSeparator(); JMenuItem exitMenu = new JMenuItem(getResourceString("EXIT")); exitMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doExit(checkForChanges()); } }); fileMenu.add(exitMenu); } menuBar.add(fileMenu); JMenu scanMenu = new JMenu(getResourceString("Scan")); menuBar.add(scanMenu); scanMI = new JMenuItem(getResourceString("Source Code")); scanMenu.add(scanMI); scanMI.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scanSources(); } }); JMenu transMenu = new JMenu(getResourceString("StrLocalizerApp.Translate")); menuBar.add(transMenu); startTransMenuItem = new JMenuItem(getResourceString("StrLocalizerApp.Start")); transMenu.add(startTransMenuItem); startTransMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { translateNewItems(); } }); transMenu.setVisible(false); stopTransMenuItem = new JMenuItem(getResourceString("Stop")); transMenu.add(stopTransMenuItem); stopTransMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { contTrans.set(false); } }); stopTransMenuItem.setEnabled(false); frame.setJMenuBar(menuBar); setTopWindow(frame); register(FRAME, frame); }
From source file:org.nuclos.client.genericobject.GenericObjectCollectController.java
protected void setupResultContextMenuStates() { this.getResultPanel().popupmenuRow.addPopupMenuListener(new PopupMenuListener() { @Override//from w w w.j a v a 2s . co m public void popupMenuWillBecomeVisible(PopupMenuEvent e) { UIUtils.runCommand(getTab(), new Runnable() { @Override public void run() { try { final List<StateVO> lstSubsequenteStates = getSubsequentStates( getSelectedCollectables()); JMenu mi = getResultPanel().miStates; mi.setVisible(lstSubsequenteStates.size() != 0); // try to find single soruce state... StateVO statevoSource = getSingleSourceStateIfAny(getSelectedCollectables()); for (final StateVO statevoTarget : lstSubsequenteStates) { final JMenuItem miStateChange = new JMenuItem( new StateChangeAction(statevoSource, statevoTarget)); miStateChange.setIcon(null); mi.add(miStateChange); } } catch (Exception e1) { getResultPanel().miStates.setVisible(false); LOG.warn("popupMenuWillBecomeVisible failed: " + e1 + ", setting it invisible"); } } }); } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { clearStatesMenu(); } @Override public void popupMenuCanceled(PopupMenuEvent e) { clearStatesMenu(); } private void clearStatesMenu() { getResultPanel().miStates.removeAll(); } }); }
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();//from w ww. ja v a 2 s . c om } }); 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:processing.app.Base.java
private void filterVisibilityOfSubsequentBoardMenus(List<JMenu> boardsCustomMenus, TargetBoard board, int fromIndex) { for (int i = fromIndex; i < boardsCustomMenus.size(); i++) { JMenu menu = boardsCustomMenus.get(i); for (int m = 0; m < menu.getItemCount(); m++) { JMenuItem menuItem = menu.getItem(m); menuItem.setVisible(menuItem.getAction().getValue("board").equals(board)); }/* w w w . ja v a 2s . co m*/ menu.setVisible(ifThereAreVisibleItemsOn(menu)); if (menu.isVisible()) { JMenuItem visibleSelectedOrFirstMenuItem = selectVisibleSelectedOrFirstMenuItem(menu); if (!visibleSelectedOrFirstMenuItem.isSelected()) { visibleSelectedOrFirstMenuItem.setSelected(true); visibleSelectedOrFirstMenuItem.getAction().actionPerformed(null); } } } }