List of usage examples for javax.swing JMenuItem setText
@BeanProperty(preferred = true, visualUpdate = true, description = "The button's text.") public void setText(String text)
From source file:be.nbb.demetra.dfm.output.simulation.RealTimePerspGraphView.java
private JMenu buildMenu() { JMenu menu = new JMenu(); JMenuItem back = new JMenuItem(new AbstractAction("Show complete data...") { @Override/*from w w w . j a v a2 s . c om*/ public void actionPerformed(ActionEvent e) { showMain(); indexSelected = -1; } }); menu.add(back); JMenuItem item = new JMenuItem(new CopyDetailAction()); item.setText("Copy current data"); menu.add(item); return menu; }
From source file:be.nbb.demetra.dfm.output.simulation.RMSEGraphView.java
private JMenu buildMenu() { JMenu menu = new JMenu(); JMenuItem item; item = new JMenuItem(new CopyAction()); item.setText("Copy data"); menu.add(item);/*from w w w . j a v a 2 s .com*/ return menu; }
From source file:de.codesourcery.eve.skills.ui.utils.PopupMenuBuilder.java
protected int populateMenu() { int itemCount = 0; for (Object obj : this.entries) { if (obj == SEPARATOR) { popupMenu.addSeparator();/*from w w w. ja v a2 s .c om*/ } else { final MyMenuItem item = (MyMenuItem) obj; final Action action = item.getAction(); final boolean isEnabled = action.isEnabled(); if (isEnabled || action instanceof IActionWithDisabledText) { final JMenuItem menuItem = new JMenuItem(action); final String text; if (isEnabled) { text = item.getLabel(); } else { text = ((IActionWithDisabledText) action).getDisabledText(); // do not render action that returns a blank/empty label if (StringUtils.isBlank(text)) { continue; } menuItem.setEnabled(false); } menuItem.setText(text); popupMenu.add(menuItem); itemCount++; } } } return itemCount; }
From source file:it.cnr.icar.eric.client.ui.swing.metal.MetalThemeMenu.java
/** * Updates the UI strings based on the current locale. *//*from w w w . j av a2 s . co m*/ protected void updateText() { for (int i = 0; i < getItemCount(); i++) { JMenuItem item = getItem(i); // item is null if there is a JSeparator at that position. if (item != null) { String itemName = item.getName(); String themeName; try { themeName = themeNames.getString(itemName); } catch (MissingResourceException mre) { themeName = itemName; Object[] noResourceArgs = { itemName, getLocale() }; MessageFormat form = new MessageFormat(themeNames.getString("message.error.noResource")); log.error(form.format(noResourceArgs)); } item.setText(themeName); } } }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopPopupButton.java
protected void initAction(final Action action, final JMenuItem menuItem) { if (initializedActions.contains(action)) return;/*from w w w .j av a 2 s . c o m*/ action.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (Action.PROP_CAPTION.equals(evt.getPropertyName())) { menuItem.setText(action.getCaption()); } else if (Action.PROP_ENABLED.equals(evt.getPropertyName())) { menuItem.setEnabled(action.isEnabled()); } else if (Action.PROP_VISIBLE.equals(evt.getPropertyName())) { menuItem.setVisible(action.isVisible()); } } }); initializedActions.add(action); }
From source file:blue.automation.AutomationManager.java
public JPopupMenu getAutomationMenu(SoundLayer soundLayer) { this.selectedSoundLayer = soundLayer; // if (menu == null || dirty) { JPopupMenu menu = new JPopupMenu(); // Build Instrument Menu JMenu instrRoot = new JMenu("Instrument"); Arrangement arrangement = data.getArrangement(); ParameterIdList paramIdList = soundLayer.getAutomationParameters(); for (int i = 0; i < arrangement.size(); i++) { InstrumentAssignment ia = arrangement.getInstrumentAssignment(i); if (ia.enabled && ia.instr instanceof Automatable) { ParameterList params = ((Automatable) ia.instr).getParameterList(); if (params.size() <= 0) { continue; }/*from w w w .j a va 2 s . c om*/ JMenu instrMenu = new JMenu(); instrMenu.setText(ia.arrangementId + ") " + ia.instr.getName()); for (int j = 0; j < params.size(); j++) { Parameter param = params.getParameter(j); JMenuItem paramItem = new JMenuItem(); paramItem.setText(param.getName()); paramItem.addActionListener(parameterActionListener); if (param.isAutomationEnabled()) { if (paramIdList.contains(param.getUniqueId())) { paramItem.setForeground(Color.GREEN); } else { paramItem.setForeground(Color.ORANGE); } } paramItem.putClientProperty("instr", ia.instr); paramItem.putClientProperty("param", param); instrMenu.add(paramItem); } instrRoot.add(instrMenu); } } menu.add(instrRoot); // Build Mixer Menu Mixer mixer = data.getMixer(); if (mixer.isEnabled()) { JMenu mixerRoot = new JMenu("Mixer"); // add channels ChannelList channels = mixer.getChannels(); if (channels.size() > 0) { JMenu channelsMenu = new JMenu("Channels"); for (int i = 0; i < channels.size(); i++) { channelsMenu.add(buildChannelMenu(channels.getChannel(i), soundLayer)); } mixerRoot.add(channelsMenu); } // add subchannels ChannelList subChannels = mixer.getSubChannels(); if (subChannels.size() > 0) { JMenu subChannelsMenu = new JMenu("Sub-Channels"); for (int i = 0; i < subChannels.size(); i++) { subChannelsMenu.add(buildChannelMenu(subChannels.getChannel(i), soundLayer)); } mixerRoot.add(subChannelsMenu); } // add master channel Channel master = mixer.getMaster(); mixerRoot.add(buildChannelMenu(master, soundLayer)); menu.add(mixerRoot); } menu.addSeparator(); JMenuItem clearAll = new JMenuItem("Clear All"); clearAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Object retVal = DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation( "Please Confirm Clearing All Parameter Data for this SoundLayer")); if (retVal == NotifyDescriptor.YES_OPTION) { ParameterIdList idList = selectedSoundLayer.getAutomationParameters(); Iterator iter = new ArrayList(idList.getParameters()).iterator(); while (iter.hasNext()) { String paramId = (String) iter.next(); Parameter param = getParameter(paramId); param.setAutomationEnabled(false); idList.removeParameterId(paramId); } } } }); menu.add(clearAll); clearAll.setEnabled(soundLayer.getAutomationParameters().size() > 0); // } // System.err.println(parameterMap); return menu; }
From source file:blue.automation.AutomationManager.java
private JMenu buildChannelMenu(Channel channel, SoundLayer soundLayer) { JMenu retVal = new JMenu(); retVal.setText(channel.getName());//from w w w.j ava2 s . co m ParameterIdList paramIdList = soundLayer.getAutomationParameters(); // pre effects EffectsChain preEffects = channel.getPreEffects(); if (preEffects.size() > 0) { JMenu preMenu = new JMenu("Pre-Effects"); retVal.add(preMenu); for (int i = 0; i < preEffects.size(); i++) { Automatable automatable = (Automatable) preEffects.getElementAt(i); ParameterList params = automatable.getParameterList(); if (params.size() > 0) { JMenu effectMenu = new JMenu(); if (automatable instanceof Effect) { effectMenu.setText(((Effect) automatable).getName()); } else if (automatable instanceof Send) { effectMenu.setText("Send: " + ((Send) automatable).getSendChannel()); } else { effectMenu.setText("ERROR"); } preMenu.add(effectMenu); for (int j = 0; j < params.size(); j++) { Parameter param = params.getParameter(j); JMenuItem paramItem = new JMenuItem(); paramItem.setText(param.getName()); paramItem.addActionListener(parameterActionListener); if (param.isAutomationEnabled()) { if (paramIdList.contains(param.getUniqueId())) { paramItem.setForeground(Color.GREEN); } else { paramItem.setForeground(Color.ORANGE); } } paramItem.putClientProperty("param", param); effectMenu.add(paramItem); } } } } // volume JMenuItem volItem = new JMenuItem("Volume"); Parameter volParam = channel.getLevelParameter(); volItem.putClientProperty("param", volParam); volItem.addActionListener(parameterActionListener); if (volParam.isAutomationEnabled()) { if (paramIdList.contains(volParam.getUniqueId())) { volItem.setForeground(Color.GREEN); } else { volItem.setForeground(Color.ORANGE); } } retVal.add(volItem); // post effects EffectsChain postEffects = channel.getPostEffects(); if (postEffects.size() > 0) { JMenu postMenu = new JMenu("Post-Effects"); retVal.add(postMenu); for (int i = 0; i < postEffects.size(); i++) { Automatable automatable = (Automatable) postEffects.getElementAt(i); ParameterList params = automatable.getParameterList(); if (params.size() > 0) { JMenu effectMenu = new JMenu(); if (automatable instanceof Effect) { effectMenu.setText(((Effect) automatable).getName()); } else if (automatable instanceof Send) { effectMenu.setText("Send: " + ((Send) automatable).getSendChannel()); } else { effectMenu.setText("ERROR"); } postMenu.add(effectMenu); for (int j = 0; j < params.size(); j++) { Parameter param = params.getParameter(j); JMenuItem paramItem = new JMenuItem(); paramItem.setText(param.getName()); paramItem.addActionListener(parameterActionListener); if (param.isAutomationEnabled()) { if (paramIdList.contains(param.getUniqueId())) { paramItem.setForeground(Color.GREEN); } else { paramItem.setForeground(Color.ORANGE); } } paramItem.putClientProperty("param", param); effectMenu.add(paramItem); } } } } return retVal; }
From source file:de.erdesignerng.visual.common.OutlineComponent.java
/** * Create the PopupMenu actions correlating to a specific tree node. * * @param aNode - the node//from www . j ava 2s .c om * @param aMenu - the menu to add the actions to * @param aRecursive - recursive */ private void initializeActionsFor(final DefaultMutableTreeNode aNode, JPopupMenu aMenu, boolean aRecursive) { Object theUserObject = aNode.getUserObject(); if (!aRecursive) { JMenuItem theExpandAllItem = new JMenuItem(); theExpandAllItem.setText(getResourceHelper().getFormattedText(ERDesignerBundle.EXPANDALL)); theExpandAllItem .addActionListener(e -> expandOrCollapseAllChildrenOfNode(new TreePath(aNode.getPath()), true)); aMenu.add(theExpandAllItem); JMenuItem theCollapseAllItem = new JMenuItem(); theCollapseAllItem.setText(getResourceHelper().getFormattedText(ERDesignerBundle.COLLAPSEALL)); theCollapseAllItem.addActionListener( e -> expandOrCollapseAllChildrenOfNode(new TreePath(aNode.getPath()), false)); aMenu.add(theCollapseAllItem); aMenu.addSeparator(); } List<ModelItem> theItemList = new ArrayList<>(); if (theUserObject instanceof ModelItem) { theItemList.add((ModelItem) theUserObject); ContextMenuFactory.addActionsToMenu(ERDesignerComponent.getDefault().getEditor(), aMenu, theItemList); } if (aNode.getParent() != null) { initializeActionsFor((DefaultMutableTreeNode) aNode.getParent(), aMenu, true); } }
From source file:uk.ac.lkl.cram.ui.ModuleFrame.java
/** * Creates new form ModuleFrame// w w w . j a va2 s .com * @param module the module that this window displays * @param file */ public ModuleFrame(final Module module, File file) { this.module = module; this.moduleFile = file; this.setTitle(module.getModuleName()); initComponents(); //Add undo mechanism undoHandler = new UndoHandler(); JMenuItem undoMI = editMenu.add(undoHandler.getUndoAction()); JMenuItem redoMI = editMenu.add(undoHandler.getRedoAction()); //Listen to the undo handler for when there is something to undo undoHandler.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { //We're assuming there's only one property //If the new value is true, then there's something to undo //And thus the save menu item should be enabled Boolean newValue = (Boolean) evt.getNewValue(); if (moduleFile != null) { saveMI.setEnabled(newValue); } } }); editMenu.addSeparator(); //Add cut, copy & paste menu items JMenuItem cutMI = editMenu.add(new JMenuItem(new DefaultEditorKit.CutAction())); cutMI.setText("Cut"); JMenuItem copyMI = editMenu.add(new JMenuItem(new DefaultEditorKit.CopyAction())); copyMI.setText("Copy"); JMenuItem pasteMI = editMenu.add(new JMenuItem(new DefaultEditorKit.PasteAction())); pasteMI.setText("Paste"); //Listen for changes to the shared selection model sharedSelectionModel.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { //Update the menu items modifyLineItemMI.setEnabled(evt.getNewValue() != null); removeLineItemMI.setEnabled(evt.getNewValue() != null); } }); doubleClickListener = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { //If the user double clicks, then treat this as a shortcut to modify the selected line item if (e.getClickCount() == 2) { modifySelectedLineItem(); } } }; //Set Accelerator keys undoMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); redoMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_Y, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); cutMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); copyMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); pasteMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); newMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); openMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); saveMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); quitMI.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_Q, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); //Remove quit menu item and separator from file menu on Mac if (Utilities.isMac()) { fileMenu.remove(quitSeparator); fileMenu.remove(quitMI); } leftTaskPaneContainer.add(createCourseDataPane()); leftTaskPaneContainer.add(createLineItemPane()); leftTaskPaneContainer.add(createTutorHoursPane()); leftTaskPaneContainer.add(createTutorCostPane()); rightTaskPaneContainer.add(createLearningTypeChartPane()); rightTaskPaneContainer.add(createLearningExperienceChartPane()); rightTaskPaneContainer.add(createLearnerFeedbackChartPane()); rightTaskPaneContainer.add(createHoursChartPane()); rightTaskPaneContainer.add(createTotalCostsPane()); }
From source file:au.org.ala.delta.editor.DeltaEditor.java
private void buildFileMenu(JMenu mnuFile) { mnuFile.removeAll();/*w ww. j a v a2s.c o m*/ String[] fileMenuActions = { "newFile", "loadFile", "closeFile", "-", "saveFile", "saveAsFile", "-", "importDirectives", "exportDirectives" }; MenuBuilder.buildMenu(mnuFile, fileMenuActions, _actionMap); mnuFile.addSeparator(); String[] previous = EditorPreferences.getPreviouslyUsedFiles(); if (previous != null && previous.length > 0) { javax.swing.Action a = this._actionMap.get("loadPreviousFile"); if (a != null) { for (int i = 0; i < previous.length; ++i) { String filename = previous[i]; JMenuItem item = new JMenuItem(); item.setAction(a); item.setText(String.format("%d %s", i + 1, filename)); item.putClientProperty("Filename", filename); item.setMnemonic(KeyEvent.VK_1 + i); mnuFile.add(item); } } } if (!isMac()) { mnuFile.addSeparator(); JMenuItem mnuItFileExit = new JMenuItem(); mnuItFileExit.setAction(_actionMap.get("exitApplication")); mnuFile.add(mnuItFileExit); } }