List of usage examples for javax.swing JMenu setEnabled
@BeanProperty(preferred = true, description = "The enabled state of the component.") public void setEnabled(boolean b)
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 w w w .j a v a 2 s.c o 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:net.sf.jabref.gui.ImportInspectionDialog.java
/** * Creates a dialog that displays the given list of fields in the table. The * dialog allows another process to add entries dynamically while the dialog * is shown./*from w w w .j av a 2 s . c o m*/ * * @param frame * @param panel */ public ImportInspectionDialog(JabRefFrame frame, BasePanel panel, String undoName, boolean newDatabase) { this.frame = frame; this.panel = panel; this.bibDatabaseContext = (panel == null) ? null : panel.getBibDatabaseContext(); this.undoName = undoName; this.newDatabase = newDatabase; setIconImage(new ImageIcon(IconTheme.getIconUrl("jabrefIcon48")).getImage()); preview = new PreviewPanel(null, bibDatabaseContext, Globals.prefs.get(JabRefPreferences.PREVIEW_0)); duplLabel.setToolTipText(Localization.lang("Possible duplicate of existing entry. Click to resolve.")); sortedList = new SortedList<>(entries); DefaultEventTableModel<BibEntry> tableModelGl = (DefaultEventTableModel<BibEntry>) GlazedListsSwing .eventTableModelWithThreadProxyList(sortedList, new EntryTableFormat()); glTable = new EntryTable(tableModelGl); GeneralRenderer renderer = new GeneralRenderer(Color.white); glTable.setDefaultRenderer(JLabel.class, renderer); glTable.setDefaultRenderer(String.class, renderer); glTable.getInputMap().put(Globals.getKeyPrefs().getKey(KeyBinding.DELETE_ENTRY), "delete"); DeleteListener deleteListener = new DeleteListener(); glTable.getActionMap().put("delete", deleteListener); selectionModel = (DefaultEventSelectionModel<BibEntry>) GlazedListsSwing .eventSelectionModelWithThreadProxyList(sortedList); glTable.setSelectionModel(selectionModel); selectionModel.getSelected().addListEventListener(new EntrySelectionListener()); comparatorChooser = TableComparatorChooser.install(glTable, sortedList, AbstractTableComparatorChooser.MULTIPLE_COLUMN_KEYBOARD); setupComparatorChooser(); glTable.addMouseListener(new TableClickListener()); setWidths(); getContentPane().setLayout(new BorderLayout()); progressBar.setIndeterminate(true); JPanel centerPan = new JPanel(); centerPan.setLayout(new BorderLayout()); contentPane.setTopComponent(new JScrollPane(glTable)); contentPane.setBottomComponent(preview); centerPan.add(contentPane, BorderLayout.CENTER); centerPan.add(progressBar, BorderLayout.SOUTH); popup.add(deleteListener); popup.addSeparator(); if (!newDatabase && (bibDatabaseContext != null)) { GroupTreeNode node = bibDatabaseContext.getMetaData().getGroups(); JMenu groupsAdd = new JMenu(Localization.lang("Add to group")); groupsAdd.setEnabled(false); // Will get enabled if there are groups that can be added to. insertNodes(groupsAdd, node); popup.add(groupsAdd); } // Add "Attach file" menu choices to right click menu: popup.add(new LinkLocalFile()); popup.add(new DownloadFile()); popup.add(new AutoSetLinks()); popup.add(new AttachUrl()); getContentPane().add(centerPan, BorderLayout.CENTER); ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue(); bb.addButton(ok); bb.addButton(stop); JButton cancel = new JButton(Localization.lang("Cancel")); bb.addButton(cancel); bb.addRelatedGap(); JButton help = new HelpAction(HelpFile.IMPORT_INSPECTION).getHelpButton(); bb.addButton(help); bb.addGlue(); bb.getPanel().setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); ButtonStackBuilder builder = new ButtonStackBuilder(); JButton selectAll = new JButton(Localization.lang("Select all")); builder.addButton(selectAll); JButton deselectAll = new JButton(Localization.lang("Deselect all")); builder.addButton(deselectAll); builder.addButton(deselectAllDuplicates); builder.addRelatedGap(); JButton delete = new JButton(Localization.lang("Delete")); builder.addButton(delete); builder.addRelatedGap(); builder.addFixed(autoGenerate); builder.addButton(generate); builder.getPanel().setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); centerPan.add(builder.getPanel(), BorderLayout.WEST); ok.setEnabled(false); generate.setEnabled(false); ok.addActionListener(new OkListener()); cancel.addActionListener(e -> { signalStopFetching(); dispose(); frame.output(Localization.lang("Import canceled by user")); }); generate.addActionListener(e -> { generate.setEnabled(false); generatedKeys = true; // To prevent the button from getting // enabled again. generateKeys(); // Generate the keys. }); stop.addActionListener(e -> { signalStopFetching(); entryListComplete(); }); selectAll.addActionListener(new SelectionButton(true)); deselectAll.addActionListener(new SelectionButton(false)); deselectAllDuplicates.addActionListener(e -> { for (int i = 0; i < glTable.getRowCount(); i++) { if (glTable.getValueAt(i, DUPL_COL) != null) { glTable.setValueAt(false, i, 0); } } glTable.repaint(); }); deselectAllDuplicates.setEnabled(false); delete.addActionListener(deleteListener); getContentPane().add(bb.getPanel(), BorderLayout.SOUTH); // Remember and default to last size: setSize(new Dimension(Globals.prefs.getInt(JabRefPreferences.IMPORT_INSPECTION_DIALOG_WIDTH), Globals.prefs.getInt(JabRefPreferences.IMPORT_INSPECTION_DIALOG_HEIGHT))); addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { contentPane.setDividerLocation(0.5f); } @Override public void windowClosed(WindowEvent e) { Globals.prefs.putInt(JabRefPreferences.IMPORT_INSPECTION_DIALOG_WIDTH, getSize().width); Globals.prefs.putInt(JabRefPreferences.IMPORT_INSPECTION_DIALOG_HEIGHT, getSize().height); } }); // Key bindings: Action closeAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }; ActionMap am = contentPane.getActionMap(); InputMap im = contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); am.put("close", closeAction); }
From source file:net.sf.jabref.gui.ImportInspectionDialog.java
private void insertNodes(JMenu menu, GroupTreeNode node) { final AbstractAction action = getAction(node); if (node.getNumberOfChildren() == 0) { menu.add(action);/*w w w . j a v a2 s . c o m*/ if (action.isEnabled()) { menu.setEnabled(true); } return; } JMenu submenu; if (node.getGroup() instanceof AllEntriesGroup) { for (GroupTreeNode child : node.getChildren()) { insertNodes(menu, child); } } else { submenu = new JMenu('[' + node.getName() + ']'); // setEnabled(true) is done above/below if at least one menu // entry (item or submenu) is enabled submenu.setEnabled(action.isEnabled()); submenu.add(action); submenu.add(new JPopupMenu.Separator()); for (GroupTreeNode child : node.getChildren()) { insertNodes(submenu, child); } menu.add(submenu); if (submenu.isEnabled()) { menu.setEnabled(true); } } }
From source file:com.limegroup.gnutella.gui.library.LibraryTableMediator.java
private JMenu createSearchSubMenu(LibraryTableDataLine dl) { JMenu menu = new JMenu(GUIMediator.getStringResource("LIBRARY_TABLE_SEARCH_POPUP_MENU")); if (dl != null) { File f = (File) dl.getInitializeObject(); String keywords = StringUtils.createQueryString(f.getName()); if (keywords.length() > 2) menu.add(new JMenuItem(new SearchAction(keywords))); LimeXMLDocument doc = dl.getXMLDocument(); if (doc != null) { Action[] actions = ActionUtils.createSearchActions(doc); for (int i = 0; i < actions.length; i++) menu.add(new JMenuItem(actions[i])); }//from w w w. j a v a 2s . co m } if (menu.getItemCount() == 0) menu.setEnabled(false); return menu; }
From source file:fi.hoski.remote.ui.Admin.java
private void menuReservation() { menuReservation = new JMenu(); TextUtil.populate(menuReservation, "RESERVATIONS"); menuBar.add(menuReservation);/* w ww.j a v a2s. co m*/ JMenu menuMakeReservation = new JMenu(); TextUtil.populate(menuMakeReservation, "MAKE RESERVATION"); menuReservation.add(menuMakeReservation); JMenu editReservation = new JMenu(); TextUtil.populate(editReservation, "EDIT RESERVATION"); menuReservation.add(editReservation); JMenu mailMenu = new JMenu(); TextUtil.populate(mailMenu, "SEND EMAIL"); menuReservation.add(mailMenu); JMenu smsMenu = new JMenu(); TextUtil.populate(smsMenu, "SEND SMS"); smsMenu.setEnabled(serverProperties.isZonerSMSSupported()); menuReservation.add(smsMenu); for (final EventType eventType : EventType.values()) { ActionListener action = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reservate(eventType, null); } }; action = createActionListener(frame, action); JMenuItem menuItem = new JMenuItem(); TextUtil.populate(menuItem, eventType.name()); menuItem.addActionListener(action); menuMakeReservation.add(menuItem); JMenuItem editItem = new JMenuItem(); TextUtil.populate(editItem, eventType.name()); ActionListener editAction = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editReservations(eventType); } }; editAction = createActionListener(frame, editAction); editItem.addActionListener(editAction); if (Event.isInspection(eventType)) { editItem.setEnabled(accessUser); } editReservation.add(editItem); JMenuItem mailItem = new JMenuItem(); TextUtil.populate(mailItem, eventType.name()); ActionListener mailAction = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { List<Event> selected = chooseEvents(eventType, "CHOOSE", true); if (selected != null && selected.size() == 1) { try { Event event = selected.get(0); List<Reservation> reservationList = dss.getReservations(event); Day date = (Day) event.get(Event.EventDate); String subject = TextUtil.getText(eventType.name()) + " " + date; String body = getMessage(eventType.name()); MailDialog md = new MailDialog(frame, subject, body, reservationList); if (md.edit()) { } } catch (AddressException ex) { throw new IllegalArgumentException(ex); } } else { JOptionPane.showMessageDialog(frame, TextUtil.getText("NO SELECTION"), TextUtil.getText("MESSAGE"), JOptionPane.INFORMATION_MESSAGE); } } }; mailAction = createActionListener(frame, mailAction); mailItem.addActionListener(mailAction); mailMenu.add(mailItem); JMenuItem smsItem = new JMenuItem(); TextUtil.populate(smsItem, eventType.name()); ActionListener smsAction = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { List<Event> selected = chooseEvents(eventType, "CHOOSE", true); if (selected != null && selected.size() == 1) { try { Event event = selected.get(0); List<Reservation> reservationList = dss.getReservations(event); List<String> phoneList = new ArrayList<String>(); for (Reservation r : reservationList) { String number = (String) r.get(Repository.JASENET_MOBILE); if (number != null) { phoneList.add(number); } } SMSDialog sd = new SMSDialog(frame, TextUtil.getText(eventType.name()), "", phoneList); if (sd.edit()) { } } catch (IOException ex) { JOptionPane.showMessageDialog(frame, ex.getMessage()); } catch (SMSException ex) { JOptionPane.showMessageDialog(frame, ex.getMessage()); } } else { JOptionPane.showMessageDialog(frame, TextUtil.getText("NO SELECTION"), TextUtil.getText("MESSAGE"), JOptionPane.INFORMATION_MESSAGE); } } }; smsAction = createActionListener(frame, smsAction); smsItem.addActionListener(smsAction); smsMenu.add(smsItem); } }
From source file:au.org.ala.delta.intkey.Intkey.java
/** * Build the settings menu/*from ww w . j a v a2s.c o m*/ * * @param actionMap * The action map for the main GUI window * @return The JMenu for the settings menu */ private JMenu buildSettingsMenu(ActionMap actionMap) { // Some menus/menu items should be disabled if no dataset is loaded. boolean isDatasetLoaded = _context.getDataset() != null; JMenu mnuSettings = new JMenu(); mnuSettings.setName("mnuSettings"); // "Set" submenu MenuBuilder mnuSetBuilder = new MenuBuilder("mnuSet", _context); mnuSetBuilder.startSubMenu("mnuAutotolerance", true); mnuSetBuilder.addOnOffDirectiveMenuItem("mnuItAutotoleranceOn", new SetAutoToleranceDirective(), true); mnuSetBuilder.addOnOffDirectiveMenuItem("mnuItAutotoleranceOff", new SetAutoToleranceDirective(), false); mnuSetBuilder.endSubMenu(); mnuSetBuilder.startSubMenu("mnuDemonstration", true); mnuSetBuilder.addOnOffDirectiveMenuItem("mnuItDemonstrationOn", new SetDemonstrationDirective(), true); mnuSetBuilder.addOnOffDirectiveMenuItem("mnuItDemonstrationOff", new SetDemonstrationDirective(), false); mnuSetBuilder.endSubMenu(); mnuSetBuilder.addDirectiveMenuItem("mnuItDiagLevel", new SetDiagLevelDirective(), true); mnuSetBuilder.startSubMenu("mnuDiagType", true); mnuSetBuilder.addDirectiveMenuItem("mnuItDiagTypeSpecimens", new SetDiagTypeSpecimensDirective(), true); mnuSetBuilder.addDirectiveMenuItem("mnuItDiagTypeTaxa", new SetDiagTypeTaxaDirective(), true); mnuSetBuilder.endSubMenu(); mnuSetBuilder.addDirectiveMenuItem("mnuItExact", new SetExactDirective(), true); mnuSetBuilder.startSubMenu("mnuFix", true); mnuSetBuilder.addOnOffDirectiveMenuItem("mnuItFixOn", new SetFixDirective(), true); mnuSetBuilder.addOnOffDirectiveMenuItem("mnuItFixOff", new SetFixDirective(), false); mnuSetBuilder.endSubMenu(); mnuSetBuilder.addDirectiveMenuItem("mnuItImagePath", new SetImagePathDirective(), true); mnuSetBuilder.addDirectiveMenuItem("mnuItInfoPath", new SetInfoPathDirective(), true); mnuSetBuilder.addDirectiveMenuItem("mnuItMatch", new SetMatchDirective(), true); mnuSetBuilder.addDirectiveMenuItem("mnuItRbase", new SetRBaseDirective(), true); mnuSetBuilder.addDirectiveMenuItem("mnuItReliabilities", new SetReliabilitiesDirective(), true); mnuSetBuilder.addDirectiveMenuItem("mnuItStopBest", new SetStopBestDirective(), true); mnuSetBuilder.addDirectiveMenuItem("mnuItTolerance", new SetToleranceDirective(), true); mnuSetBuilder.addDirectiveMenuItem("mnuItVaryWt", new SetVaryWtDirective(), true); mnuSettings.add(mnuSetBuilder.getMenu()); // "Display" submenu MenuBuilder mnuDisplayBuilder = new MenuBuilder("mnuDisplay", _context); mnuDisplayBuilder.startSubMenu("mnuCharacterOrder", true); mnuDisplayBuilder.addDirectiveMenuItem("mnuItCharacterOrderBest", new DisplayCharacterOrderBestDirective(), true); mnuDisplayBuilder.addDirectiveMenuItem("mnuItCharacterOrderNatural", new DisplayCharacterOrderNaturalDirective(), true); mnuDisplayBuilder.addDirectiveMenuItem("mnuItCharacterOrderSeparate", new DisplayCharacterOrderSeparateDirective(), true); mnuDisplayBuilder.endSubMenu(); mnuDisplayBuilder.startSubMenu("mnuComments", true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItCommentsOn", new DisplayCommentsDirective(), true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItCommentsOff", new DisplayCommentsDirective(), false); mnuDisplayBuilder.endSubMenu(); mnuDisplayBuilder.startSubMenu("mnuContinuous", true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItContinuousOn", new DisplayContinuousDirective(), true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItContinuousOff", new DisplayContinuousDirective(), false); mnuDisplayBuilder.endSubMenu(); mnuDisplayBuilder.startSubMenu("mnuEndIdentify", true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItEndIdentifyOn", new DisplayEndIdentifyDirective(), true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItEndIdentifyOff", new DisplayEndIdentifyDirective(), false); mnuDisplayBuilder.endSubMenu(); mnuDisplayBuilder.addDirectiveMenuItem("mnuItImages", new DisplayImagesDirective(), true); mnuDisplayBuilder.startSubMenu("mnuInapplicables", true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItInapplicablesOn", new DisplayInapplicablesDirective(), true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItInapplicablesOff", new DisplayInapplicablesDirective(), false); mnuDisplayBuilder.endSubMenu(); mnuDisplayBuilder.startSubMenu("mnuInput", true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItInputOn", new DisplayInputDirective(), true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItInputOff", new DisplayInputDirective(), false); mnuDisplayBuilder.endSubMenu(); mnuDisplayBuilder.startSubMenu("mnuKeywords", true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItKeywordsOn", new DisplayKeywordsDirective(), true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItKeywordsOff", new DisplayKeywordsDirective(), false); mnuDisplayBuilder.endSubMenu(); mnuDisplayBuilder.startSubMenu("mnuLog", true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItLogOn", new DisplayLogDirective(), true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItLogOff", new DisplayLogDirective(), false); mnuDisplayBuilder.endSubMenu(); mnuDisplayBuilder.startSubMenu("mnuNumbering", true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItNumberingOn", new DisplayNumberingDirective(), true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItNumberingOff", new DisplayNumberingDirective(), false); mnuDisplayBuilder.endSubMenu(); mnuDisplayBuilder.startSubMenu("mnuScaled", true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItScaledOn", new DisplayScaledDirective(), true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItScaledOff", new DisplayScaledDirective(), false); mnuDisplayBuilder.endSubMenu(); mnuDisplayBuilder.startSubMenu("mnuUnknowns", true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItUnknownsOn", new DisplayUnknownsDirective(), true); mnuDisplayBuilder.addOnOffDirectiveMenuItem("mnuItUnknownsOff", new DisplayUnknownsDirective(), false); mnuDisplayBuilder.endSubMenu(); mnuSettings.add(mnuDisplayBuilder.getMenu()); // "Define" submenu MenuBuilder mnuDefineBuilder = new MenuBuilder("mnuDefine", _context); mnuDefineBuilder.addDirectiveMenuItem("mnuItDefineCharacters", new DefineCharactersDirective(), isDatasetLoaded); mnuDefineBuilder.addDirectiveMenuItem("mnuItDefineTaxa", new DefineTaxaDirective(), isDatasetLoaded); mnuDefineBuilder.addDirectiveMenuItem("mnuItDefineNames", new DefineNamesDirective(), isDatasetLoaded); mnuDefineBuilder.addDirectiveMenuItem("mnuItDefineButton", new DefineButtonDirective(), isDatasetLoaded); mnuDefineBuilder.addDirectiveMenuItem("mnuItDefineEndIdentify", new DefineEndIdentifyDirective(), isDatasetLoaded); mnuDefineBuilder.addDirectiveMenuItem("mnuItDefineInformation", new DefineInformationDirective(), isDatasetLoaded); mnuDefineBuilder.addDirectiveMenuItem("mnuItDefineSubjects", new DefineSubjectsDirective(), isDatasetLoaded); JMenu mnuDefine = mnuDefineBuilder.getMenu(); mnuDefine.setEnabled(isDatasetLoaded); mnuSettings.add(mnuDefineBuilder.getMenu()); // "Include" submenu MenuBuilder mnuIncludeBuilder = new MenuBuilder("mnuInclude", _context); mnuIncludeBuilder.addDirectiveMenuItem("mnuItIncludeCharacters", new IncludeCharactersDirective(), isDatasetLoaded); mnuIncludeBuilder.addDirectiveMenuItem("mnuItIncludeTaxa", new IncludeTaxaDirective(), isDatasetLoaded); JMenu mnuInclude = mnuIncludeBuilder.getMenu(); mnuInclude.setEnabled(isDatasetLoaded); mnuSettings.add(mnuInclude); // "Exclude" submenu MenuBuilder mnuExcludeBuilder = new MenuBuilder("mnuExclude", _context); mnuExcludeBuilder.addDirectiveMenuItem("mnuItExcludeCharacters", new ExcludeCharactersDirective(), isDatasetLoaded); mnuExcludeBuilder.addDirectiveMenuItem("mnuItExcludeTaxa", new ExcludeTaxaDirective(), isDatasetLoaded); JMenu mnuExclude = mnuExcludeBuilder.getMenu(); mnuExclude.setEnabled(isDatasetLoaded); mnuSettings.add(mnuExclude); // "Status" submenu MenuBuilder mnuStatusBuilder = new MenuBuilder("mnuStatus", _context); mnuStatusBuilder.addDirectiveMenuItem("mnuItStatusDisplay", new StatusDisplayDirective(), isDatasetLoaded); mnuStatusBuilder.startSubMenu("mnuStatusInclude", true); mnuStatusBuilder.addDirectiveMenuItem("mnuItStatusIncludeCharacters", new StatusIncludeCharactersDirective(), isDatasetLoaded); mnuStatusBuilder.addDirectiveMenuItem("mnuItStatusIncludeTaxa", new StatusIncludeTaxaDirective(), isDatasetLoaded); mnuStatusBuilder.endSubMenu(); mnuStatusBuilder.startSubMenu("mnuStatusExclude", true); mnuStatusBuilder.addDirectiveMenuItem("mnuItStatusExcludeCharacters", new StatusExcludeCharactersDirective(), isDatasetLoaded); mnuStatusBuilder.addDirectiveMenuItem("mnuItStatusExcludeTaxa", new StatusExcludeTaxaDirective(), isDatasetLoaded); mnuStatusBuilder.endSubMenu(); mnuStatusBuilder.addDirectiveMenuItem("mnuItStatusFiles", new StatusFilesDirective(), isDatasetLoaded); mnuStatusBuilder.addDirectiveMenuItem("mnuItStatusSet", new StatusSetDirective(), isDatasetLoaded); mnuStatusBuilder.addDirectiveMenuItem("mnuItStatusAll", new StatusAllDirective(), isDatasetLoaded); mnuSettings.add(mnuStatusBuilder.getMenu()); return mnuSettings; }
From source file:au.org.ala.delta.intkey.Intkey.java
/** * Build the browsing menu//from w ww. j a v a 2s . co m * * @param actionMap * The action map for the main GUI window * @return The JMenu for the browsing menu */ private JMenu buildBrowsingMenu(ActionMap actionMap) { // Some menus/menu items should be disabled if no dataset is loaded. boolean isDatasetLoaded = _context.getDataset() != null; JMenu mnuBrowsing = new JMenu(); mnuBrowsing.setName("mnuBrowsing"); JMenuItem mnuItCharacters = new JMenuItem(new DirectiveAction(new CharactersDirective(), _context)); mnuItCharacters.setName("mnuItCharacters"); mnuItCharacters.setEnabled(isDatasetLoaded); mnuBrowsing.add(mnuItCharacters); JMenuItem mnuItTaxa = new JMenuItem(new DirectiveAction(new TaxaDirective(), _context)); mnuItTaxa.setName("mnuItTaxa"); mnuItTaxa.setEnabled(isDatasetLoaded); mnuBrowsing.add(mnuItTaxa); mnuBrowsing.addSeparator(); JMenu mnuFind = new JMenu(); mnuFind.setName("mnuFind"); JMenuItem mnuItFindCharacters = new JMenuItem(new DirectiveAction(new FindCharactersDirective(), _context)); mnuItFindCharacters.setName("mnuItFindCharacters"); mnuItFindCharacters.setEnabled(isDatasetLoaded); mnuFind.add(mnuItFindCharacters); JMenuItem mnuItFindTaxa = new JMenuItem(new DirectiveAction(new FindTaxaDirective(), _context)); mnuItFindTaxa.setName("mnuItFindTaxa"); mnuItFindTaxa.setEnabled(isDatasetLoaded); mnuFind.setEnabled(isDatasetLoaded); mnuFind.add(mnuItFindTaxa); mnuBrowsing.add(mnuFind); mnuBrowsing.addSeparator(); JMenu mnuIllustrate = new JMenu(); mnuIllustrate.setName("mnuIllustrate"); JMenuItem mnuItIllustrateCharacters = new JMenuItem( new DirectiveAction(new IllustrateCharactersDirective(), _context)); mnuItIllustrateCharacters.setName("mnuItIllustrateCharacters"); mnuItIllustrateCharacters.setEnabled(isDatasetLoaded); mnuIllustrate.add(mnuItIllustrateCharacters); JMenuItem mnuItIllustrateTaxa = new JMenuItem(new DirectiveAction(new IllustrateTaxaDirective(), _context)); mnuItIllustrateTaxa.setName("mnuItIllustrateTaxa"); mnuItIllustrateTaxa.setEnabled(isDatasetLoaded); mnuIllustrate.setEnabled(isDatasetLoaded); mnuIllustrate.add(mnuItIllustrateTaxa); mnuBrowsing.add(mnuIllustrate); mnuBrowsing.addSeparator(); JMenuItem mnuItInformation = new JMenuItem(new DirectiveAction(new InformationDirective(), _context)); mnuItInformation.setName("mnuItInformation"); mnuItInformation.setEnabled(isDatasetLoaded); mnuBrowsing.add(mnuItInformation); return mnuBrowsing; }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.analise_geral.PanelAnaliseGeral.java
/** * Cria o menu editar do Frame Principal * //from ww w . ja v a2 s .c o m * @param menu */ private JMenu criaMenuEditar() { JMenu menu = new JMenu(GERAL.EDITAR); menu.setBackground(parentFrame.corDefault); menu.setMnemonic('E'); menu.setMnemonic(KeyEvent.VK_E); JMenuItem btnContraste = new JMenuItem(GERAL.ALTERAR_CONTRASTE); btnContraste.addActionListener(this); btnContraste.setActionCommand("Contraste"); // btnAumenta.setMnemonic('F'); // btnAumenta.setMnemonic(KeyEvent.VK_F); // btnAumenta.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ADD, // ActionEvent.CTRL_MASK)); btnContraste.setToolTipText(GERAL.DICA_CONTRASTE); btnContraste.getAccessibleContext().setAccessibleDescription(GERAL.DICA_CONTRASTE); menu.add(btnContraste); JMenuItem btnAumenta = new JMenuItem(GERAL.AUMENTA_FONTE); btnAumenta.addActionListener(this); btnAumenta.setActionCommand("AumentaFonte"); // btnAumenta.setMnemonic('F'); // btnAumenta.setMnemonic(KeyEvent.VK_F); btnAumenta.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ADD, ActionEvent.CTRL_MASK)); btnAumenta.setToolTipText(GERAL.DICA_AUMENTA_FONTE); btnAumenta.getAccessibleContext().setAccessibleDescription(GERAL.DICA_AUMENTA_FONTE); menu.add(btnAumenta); JMenuItem btnDiminui = new JMenuItem(GERAL.DIMINUI_FONTE); btnDiminui.addActionListener(this); btnDiminui.setActionCommand("DiminuiFonte"); // btnDiminui.setMnemonic('F'); // btnDiminui.setMnemonic(KeyEvent.VK_F); btnDiminui.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_SUBTRACT, ActionEvent.CTRL_MASK)); btnDiminui.setToolTipText(GERAL.DICA_DIMINUI_FONTE); btnDiminui.getAccessibleContext().setAccessibleDescription(GERAL.DICA_DIMINUI_FONTE); menu.add(btnDiminui); menu.add(new JSeparator()); JMenuItem btnProcurar = new JMenuItem(GERAL.PROCURAR); btnProcurar.addActionListener(this); btnProcurar.setActionCommand("Procurar"); btnProcurar.setMnemonic('P'); btnProcurar.setMnemonic(KeyEvent.VK_P); btnProcurar.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, ActionEvent.CTRL_MASK)); btnProcurar.setToolTipText(GERAL.DICA_PROCURAR); btnProcurar.getAccessibleContext().setAccessibleDescription(GERAL.DICA_PROCURAR); menu.add(btnProcurar); JMenuItem btnSelecionarTudo = new JMenuItem(GERAL.SELECIONAR_TUDO); btnSelecionarTudo.addActionListener(this); btnSelecionarTudo.setActionCommand("SelecionarTudo"); btnSelecionarTudo.setMnemonic('T'); btnSelecionarTudo.setMnemonic(KeyEvent.VK_T); btnSelecionarTudo.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, ActionEvent.CTRL_MASK)); btnSelecionarTudo.setToolTipText(GERAL.DICA_SELECIONAR_TUDO); btnSelecionarTudo.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SELECIONAR_TUDO); menu.add(btnSelecionarTudo); JMenuItem btnDesfazer = new JMenuItem(GERAL.DESFAZER); btnDesfazer.addActionListener(this); btnDesfazer.setActionCommand("Desfazer"); btnDesfazer.setMnemonic('z'); btnDesfazer.setMnemonic(KeyEvent.VK_Z); btnDesfazer.getAccessibleContext().setAccessibleDescription(GERAL.DICA_DESFAZER); btnDesfazer.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, ActionEvent.CTRL_MASK)); menu.add(btnDesfazer); menu.setEnabled(true); return menu; }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.label.PainelLabel.java
/** * Cria o menu editar do Frame Principal * // ww w . j a v a2 s . c o m * @param menu */ private JMenu criaMenuEditar() { JMenu menu = new JMenu(GERAL.EDITAR); menu.setBackground(parentFrame.corDefault); menu.setMnemonic('E'); menu.setMnemonic(KeyEvent.VK_E); JMenuItem btnContraste = new JMenuItem(GERAL.ALTERAR_CONTRASTE); btnContraste.addActionListener(this); btnContraste.setActionCommand("Contraste"); // btnAumenta.setMnemonic('F'); // btnAumenta.setMnemonic(KeyEvent.VK_F); // btnAumenta.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ADD, // ActionEvent.CTRL_MASK)); btnContraste.setToolTipText(GERAL.DICA_CONTRASTE); btnContraste.getAccessibleContext().setAccessibleDescription(GERAL.DICA_CONTRASTE); menu.add(btnContraste); JMenuItem btnAumenta = new JMenuItem(GERAL.AUMENTA_FONTE); btnAumenta.addActionListener(this); btnAumenta.setActionCommand("AumentaFonte"); // btnAumenta.setMnemonic('F'); // btnAumenta.setMnemonic(KeyEvent.VK_F); btnAumenta.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ADD, ActionEvent.CTRL_MASK)); btnAumenta.setToolTipText(GERAL.DICA_AUMENTA_FONTE); btnAumenta.getAccessibleContext().setAccessibleDescription(GERAL.DICA_AUMENTA_FONTE); menu.add(btnAumenta); JMenuItem btnDiminui = new JMenuItem(GERAL.DIMINUI_FONTE); btnDiminui.addActionListener(this); btnDiminui.setActionCommand("DiminuiFonte"); // btnDiminui.setMnemonic('F'); // btnDiminui.setMnemonic(KeyEvent.VK_F); btnDiminui.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_SUBTRACT, ActionEvent.CTRL_MASK)); btnDiminui.setToolTipText(GERAL.DICA_DIMINUI_FONTE); btnDiminui.getAccessibleContext().setAccessibleDescription(GERAL.DICA_DIMINUI_FONTE); menu.add(btnDiminui); menu.add(new JSeparator()); JMenuItem btnProcurar = new JMenuItem(GERAL.PROCURAR); btnProcurar.addActionListener(this); btnProcurar.setActionCommand("Procurar"); btnProcurar.setMnemonic('P'); btnProcurar.setMnemonic(KeyEvent.VK_P); btnProcurar.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, ActionEvent.CTRL_MASK)); btnProcurar.setToolTipText(GERAL.DICA_PROCURAR); btnProcurar.getAccessibleContext().setAccessibleDescription(GERAL.DICA_PROCURAR); menu.add(btnProcurar); JMenuItem btnSelecionarTudo = new JMenuItem(GERAL.SELECIONAR_TUDO); btnSelecionarTudo.addActionListener(this); btnSelecionarTudo.setActionCommand("SelecionarTudo"); btnSelecionarTudo.setMnemonic('T'); btnSelecionarTudo.setMnemonic(KeyEvent.VK_T); btnSelecionarTudo.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, ActionEvent.CTRL_MASK)); btnSelecionarTudo.setToolTipText(GERAL.DICA_SELECIONAR_TODO_CSS); btnSelecionarTudo.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SELECIONAR_TODO_CSS); menu.add(btnSelecionarTudo); JMenuItem btnDesfazer = new JMenuItem(GERAL.DESFAZER); btnDesfazer.addActionListener(this); btnDesfazer.setActionCommand("Desfazer"); btnDesfazer.setMnemonic('z'); btnDesfazer.setMnemonic(KeyEvent.VK_Z); btnDesfazer.getAccessibleContext().setAccessibleDescription(GERAL.DICA_DESFAZER); btnDesfazer.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, ActionEvent.CTRL_MASK)); menu.add(btnDesfazer); menu.setEnabled(true); return menu; }
From source file:org.datacleaner.panels.DatabaseDriversPanel.java
private void updateComponents() { this.removeAll(); final PopupButton addDriverButton = WidgetFactory.createDefaultPopupButton("Add database driver", IconUtils.ACTION_ADD);//from w w w . j a v a2 s . co m final JPopupMenu addDriverMenu = addDriverButton.getMenu(); final JMenu automaticDownloadAndInstallMenu = new JMenu("Automatic download and install"); automaticDownloadAndInstallMenu .setIcon(imageManager.getImageIcon(IconUtils.ACTION_DOWNLOAD, IconUtils.ICON_SIZE_MENU_ITEM)); final List<DatabaseDriverDescriptor> drivers = _databaseDriverCatalog.getDatabaseDrivers(); for (DatabaseDriverDescriptor dd : drivers) { final String[] urls = dd.getDownloadUrls(); if (urls != null && _databaseDriverCatalog.getState(dd) == DatabaseDriverState.NOT_INSTALLED) { final JMenuItem downloadAndInstallMenuItem = WidgetFactory.createMenuItem(dd.getDisplayName(), dd.getIconImagePath()); downloadAndInstallMenuItem.addActionListener(createDownloadActionListener(dd)); automaticDownloadAndInstallMenu.add(downloadAndInstallMenuItem); } } if (automaticDownloadAndInstallMenu.getMenuComponentCount() == 0) { automaticDownloadAndInstallMenu.setEnabled(false); } final JMenuItem localJarFilesMenuItem = WidgetFactory.createMenuItem("Local JAR file(s)...", IconUtils.FILE_ARCHIVE); localJarFilesMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { AddDatabaseDriverDialog dialog = new AddDatabaseDriverDialog(_databaseDriverCatalog, DatabaseDriversPanel.this, _windowContext, _userPreferences); dialog.setVisible(true); } }); addDriverMenu.add(automaticDownloadAndInstallMenu); addDriverMenu.add(localJarFilesMenuItem); final DCTable table = getDatabaseDriverTable(); this.add(DCPanel.flow(Alignment.RIGHT, addDriverButton), BorderLayout.NORTH); this.add(table.toPanel(), BorderLayout.CENTER); }