List of usage examples for javax.swing JMenuItem addActionListener
public void addActionListener(ActionListener l)
ActionListener
to the button. From source file:be.ac.ua.comp.scarletnebula.gui.windows.GUI.java
private JMenu getServerMenu() { final JMenu serverMenu = new JMenu("Servers"); serverMenu.setMnemonic(KeyEvent.VK_S); final JMenuItem startServerItem = new JMenuItem("Start new server", Utils.icon("add16.png")); startServerItem.setMnemonic(KeyEvent.VK_S); startServerItem.addActionListener(new ActionListener() { @Override/* www.j a v a 2 s. c o m*/ public void actionPerformed(final ActionEvent e) { startAddServerWizard(); } }); serverMenu.add(startServerItem); final JMenuItem searchServerItem = new JMenuItem("Filter servers", Utils.icon("search16.png")); searchServerItem.setMnemonic(KeyEvent.VK_F); searchServerItem.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { showFilter(); } }); serverMenu.add(searchServerItem); return serverMenu; }
From source file:edu.ku.brc.specify.config.init.SpecifyDBSetupWizardFrame.java
/** * @return//from w ww . j a v a 2s.c o m */ public JMenuBar createMenus() { JMenuBar mb = new JMenuBar(); JMenuItem mi; //-------------------------------------------------------------------- //-- File Menu //-------------------------------------------------------------------- if (UIHelper.getOSType() != UIHelper.OSTYPE.MacOSX) { JMenu menu = UIHelper.createLocalizedMenu(mb, "Specify.FILE_MENU", "Specify.FILE_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$ menu.addSeparator(); String title = "Specify.EXIT"; //$NON-NLS-1$ String mnu = "Specify.Exit_MNEU"; //$NON-NLS-1$ mi = UIHelper.createLocalizedMenuItem(menu, title, mnu, title, true, null); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { doExit(true); } }); } helpMenu = UIHelper.createLocalizedMenu(mb, "Specify.HELP_MENU", "Specify.HELP_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$ HelpMgr.createHelpMenuItem(helpMenu, "Specify"); //$NON-NLS-1$ helpMenu.addSeparator(); if (UIHelper.getOSType() != UIHelper.OSTYPE.MacOSX) { String ttle = "Specify.ABOUT";//$NON-NLS-1$ String mneu = "Specify.ABOUTMNEU";//$NON-NLS-1$ String desc = "Specify.ABOUT";//$NON-NLS-1$ mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { doAbout(); } }); } return mb; }
From source file:edu.virginia.iath.oxygenplugins.juel.JUELPluginMenu.java
public JUELPluginMenu(StandalonePluginWorkspace spw, LocalOptions ops) { super(name, true); ws = spw;/*from w ww .j a v a 2s.co m*/ options = ops; // setup the options //options.readStorage(); // Find names JMenuItem search = new JMenuItem("Find Name"); search.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent selection) { String label = "Find Name"; final JTextField lastName = new JTextField("", 30); lastName.setPreferredSize(new Dimension(350, 25)); //JTextField projectName = new JTextField("", 30); final JComboBox possibleVals = new JComboBox(); possibleVals.setEnabled(false); possibleVals.setPreferredSize(new Dimension(350, 25)); JButton search = new JButton("Search"); search.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent selection) { // query the database try { String json = ""; String line; URL url = new URL("http://juel.iath.virginia.edu/academical_db/people/find_people?term=" + lastName.getText()); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); while ((line = in.readLine()) != null) { json += line; } JSONArray obj = new JSONArray(json); // Read the JSON and update possibleVals possibleVals.removeAllItems(); possibleVals.setEnabled(false); for (int i = 0; i < obj.length(); i++) { JSONObject cur = obj.getJSONObject(i); String name = cur.getString("label"); String id = String.format("P%05d", cur.getInt("value")); possibleVals.addItem(new ComboBoxObject(name, id)); possibleVals.setEnabled(true); } } catch (Exception e) { e.printStackTrace(); possibleVals.setEnabled(false); } return; } }); search.setPreferredSize(new Dimension(100, 25)); JButton insert = new JButton("Insert"); insert.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent sel) { // Insert into the page // Get the selected value, grab the ID, then insert into the document // Get the editor WSTextEditorPage ed = null; WSEditor editorAccess = ws .getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA); if (editorAccess != null && editorAccess.getCurrentPage() instanceof WSTextEditorPage) { ed = (WSTextEditorPage) editorAccess.getCurrentPage(); } String result = "key=\"" + ((ComboBoxObject) possibleVals.getSelectedItem()).id + "\""; // Update the text in the document ed.beginCompoundUndoableEdit(); int selectionOffset = ed.getSelectionStart(); ed.deleteSelection(); javax.swing.text.Document doc = ed.getDocument(); try { if (selectionOffset > 0 && !doc.getText(selectionOffset - 1, 1).equals(" ")) result = " " + result; if (selectionOffset > 0 && !doc.getText(selectionOffset, 1).equals(" ") && !doc.getText(selectionOffset, 1).equals(">")) result = result + " "; doc.insertString(selectionOffset, result, javax.swing.text.SimpleAttributeSet.EMPTY); } catch (javax.swing.text.BadLocationException b) { // Okay if it doesn't work } ed.endCompoundUndoableEdit(); return; } }); insert.setPreferredSize(new Dimension(100, 25)); java.awt.GridLayout layoutOuter = new java.awt.GridLayout(3, 1); java.awt.FlowLayout layout = new java.awt.FlowLayout(FlowLayout.RIGHT); // rows, columns JPanel addPanel = new JPanel(); JPanel addPanelInner = new JPanel(); addPanel.setLayout(layoutOuter); addPanel.add(new JLabel("Search for last name, then choose a full name from the list below")); addPanelInner.setLayout(layout); addPanelInner.add(new JLabel("Search Last Name: ")); addPanelInner.add(lastName); addPanelInner.add(search); addPanel.add(addPanelInner); addPanelInner = new JPanel(); addPanelInner.setLayout(layout); addPanelInner.add(new JLabel("Narrow Search: ")); addPanelInner.add(possibleVals); addPanelInner.add(insert); addPanel.add(addPanelInner); JOptionPane.showMessageDialog((java.awt.Frame) ws.getParentFrame(), addPanel, label, JOptionPane.PLAIN_MESSAGE); } }); this.add(search); // Find places search = new JMenuItem("Find Place"); search.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent selection) { String label = "Find Place"; final JTextField searchText = new JTextField("", 30); searchText.setPreferredSize(new Dimension(350, 25)); //JTextField projectName = new JTextField("", 30); final JComboBox possibleVals = new JComboBox(); possibleVals.setEnabled(false); possibleVals.setPreferredSize(new Dimension(350, 25)); JButton search = new JButton("Search"); search.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent selection) { // query the database try { String json = ""; String line; URL url = new URL( "http://academical.village.virginia.edu/academical_db/places/find_places?term=" + searchText.getText()); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); while ((line = in.readLine()) != null) { json += line; } JSONArray obj = new JSONArray(json); // Read the JSON and update possibleVals possibleVals.removeAllItems(); possibleVals.setEnabled(false); for (int i = 0; i < obj.length(); i++) { JSONObject cur = obj.getJSONObject(i); String id = String.format("PL%04d", cur.getInt("value")); String name = cur.getString("label") + " (" + id + ")"; possibleVals.addItem(new ComboBoxObject(name, id)); possibleVals.setEnabled(true); } } catch (Exception e) { e.printStackTrace(); possibleVals.setEnabled(false); } return; } }); search.setPreferredSize(new Dimension(100, 25)); JButton insert = new JButton("Insert"); insert.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent sel) { // Insert into the page // Get the selected value, grab the ID, then insert into the document // Get the editor WSTextEditorPage ed = null; WSEditor editorAccess = ws .getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA); if (editorAccess != null && editorAccess.getCurrentPage() instanceof WSTextEditorPage) { ed = (WSTextEditorPage) editorAccess.getCurrentPage(); } String result = "key=\"" + ((ComboBoxObject) possibleVals.getSelectedItem()).id + "\""; // Update the text in the document ed.beginCompoundUndoableEdit(); int selectionOffset = ed.getSelectionStart(); ed.deleteSelection(); javax.swing.text.Document doc = ed.getDocument(); try { if (selectionOffset > 0 && !doc.getText(selectionOffset - 1, 1).equals(" ")) result = " " + result; if (selectionOffset > 0 && !doc.getText(selectionOffset, 1).equals(" ") && !doc.getText(selectionOffset, 1).equals(">")) result = result + " "; doc.insertString(selectionOffset, result, javax.swing.text.SimpleAttributeSet.EMPTY); } catch (javax.swing.text.BadLocationException b) { // Okay if it doesn't work } ed.endCompoundUndoableEdit(); return; } }); insert.setPreferredSize(new Dimension(100, 25)); java.awt.GridLayout layoutOuter = new java.awt.GridLayout(3, 1); java.awt.FlowLayout layout = new java.awt.FlowLayout(FlowLayout.RIGHT); // rows, columns JPanel addPanel = new JPanel(); JPanel addPanelInner = new JPanel(); addPanel.setLayout(layoutOuter); addPanel.add(new JLabel("Search for a place name, then choose one from the list below")); addPanelInner.setLayout(layout); addPanelInner.add(new JLabel("Search Keyword: ")); addPanelInner.add(searchText); addPanelInner.add(search); addPanel.add(addPanelInner); addPanelInner = new JPanel(); addPanelInner.setLayout(layout); addPanelInner.add(new JLabel("Narrow Search: ")); addPanelInner.add(possibleVals); addPanelInner.add(insert); addPanel.add(addPanelInner); JOptionPane.showMessageDialog((java.awt.Frame) ws.getParentFrame(), addPanel, label, JOptionPane.PLAIN_MESSAGE); } }); this.add(search); // Find corporate bodies search = new JMenuItem("Find Corporate Body"); search.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent selection) { String label = "Find Corporate Body"; final JTextField searchText = new JTextField("", 30); searchText.setPreferredSize(new Dimension(350, 25)); //JTextField projectName = new JTextField("", 30); final JComboBox possibleVals = new JComboBox(); possibleVals.setEnabled(false); possibleVals.setPreferredSize(new Dimension(350, 25)); JButton search = new JButton("Search"); search.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent selection) { // query the database try { String json = ""; String line; URL url = new URL( "http://academical.village.virginia.edu/academical_db/corporate_bodies/find?term=" + searchText.getText()); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); while ((line = in.readLine()) != null) { json += line; } JSONArray obj = new JSONArray(json); // Read the JSON and update possibleVals possibleVals.removeAllItems(); possibleVals.setEnabled(false); for (int i = 0; i < obj.length(); i++) { JSONObject cur = obj.getJSONObject(i); String id = String.format("CB%04d", cur.getInt("value")); String name = cur.getString("label") + " (" + id + ")"; possibleVals.addItem(new ComboBoxObject(name, id)); possibleVals.setEnabled(true); } } catch (Exception e) { e.printStackTrace(); possibleVals.setEnabled(false); } return; } }); search.setPreferredSize(new Dimension(100, 25)); JButton insert = new JButton("Insert"); insert.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent sel) { // Insert into the page // Get the selected value, grab the ID, then insert into the document // Get the editor WSTextEditorPage ed = null; WSEditor editorAccess = ws .getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA); if (editorAccess != null && editorAccess.getCurrentPage() instanceof WSTextEditorPage) { ed = (WSTextEditorPage) editorAccess.getCurrentPage(); } String result = "key=\"" + ((ComboBoxObject) possibleVals.getSelectedItem()).id + "\""; // Update the text in the document ed.beginCompoundUndoableEdit(); int selectionOffset = ed.getSelectionStart(); ed.deleteSelection(); javax.swing.text.Document doc = ed.getDocument(); try { if (selectionOffset > 0 && !doc.getText(selectionOffset - 1, 1).equals(" ")) result = " " + result; if (selectionOffset > 0 && !doc.getText(selectionOffset, 1).equals(" ") && !doc.getText(selectionOffset, 1).equals(">")) result = result + " "; doc.insertString(selectionOffset, result, javax.swing.text.SimpleAttributeSet.EMPTY); } catch (javax.swing.text.BadLocationException b) { // Okay if it doesn't work } ed.endCompoundUndoableEdit(); return; } }); insert.setPreferredSize(new Dimension(100, 25)); java.awt.GridLayout layoutOuter = new java.awt.GridLayout(3, 1); java.awt.FlowLayout layout = new java.awt.FlowLayout(FlowLayout.RIGHT); // rows, columns JPanel addPanel = new JPanel(); JPanel addPanelInner = new JPanel(); addPanel.setLayout(layoutOuter); addPanel.add(new JLabel("Search for a corporate body, then one from the list below")); addPanelInner.setLayout(layout); addPanelInner.add(new JLabel("Search Keyword: ")); addPanelInner.add(searchText); addPanelInner.add(search); addPanel.add(addPanelInner); addPanelInner = new JPanel(); addPanelInner.setLayout(layout); addPanelInner.add(new JLabel("Narrow Search: ")); addPanelInner.add(possibleVals); addPanelInner.add(insert); addPanel.add(addPanelInner); JOptionPane.showMessageDialog((java.awt.Frame) ws.getParentFrame(), addPanel, label, JOptionPane.PLAIN_MESSAGE); } }); this.add(search); // Find Courses search = new JMenuItem("Find Course"); search.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent selection) { String label = "Find Course"; final JTextField searchText = new JTextField("", 30); searchText.setPreferredSize(new Dimension(350, 25)); //JTextField projectName = new JTextField("", 30); final JComboBox possibleVals = new JComboBox(); possibleVals.setEnabled(false); possibleVals.setPreferredSize(new Dimension(350, 25)); JButton search = new JButton("Search"); search.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent selection) { // query the database try { String json = ""; String line; URL url = new URL( "http://academical.village.virginia.edu/academical_db/courses/find?term=" + searchText.getText()); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); while ((line = in.readLine()) != null) { json += line; } JSONArray obj = new JSONArray(json); // Read the JSON and update possibleVals possibleVals.removeAllItems(); possibleVals.setEnabled(false); for (int i = 0; i < obj.length(); i++) { JSONObject cur = obj.getJSONObject(i); String id = String.format("C%04d", cur.getInt("value")); String name = cur.getString("label") + " (" + id + ")"; possibleVals.addItem(new ComboBoxObject(name, id)); possibleVals.setEnabled(true); } } catch (Exception e) { e.printStackTrace(); possibleVals.setEnabled(false); } return; } }); search.setPreferredSize(new Dimension(100, 25)); JButton insert = new JButton("Insert"); insert.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent sel) { // Insert into the page // Get the selected value, grab the ID, then insert into the document // Get the editor WSTextEditorPage ed = null; WSEditor editorAccess = ws .getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA); if (editorAccess != null && editorAccess.getCurrentPage() instanceof WSTextEditorPage) { ed = (WSTextEditorPage) editorAccess.getCurrentPage(); } String result = "key=\"" + ((ComboBoxObject) possibleVals.getSelectedItem()).id + "\""; // Update the text in the document ed.beginCompoundUndoableEdit(); int selectionOffset = ed.getSelectionStart(); ed.deleteSelection(); javax.swing.text.Document doc = ed.getDocument(); try { if (selectionOffset > 0 && !doc.getText(selectionOffset - 1, 1).equals(" ")) result = " " + result; if (selectionOffset > 0 && !doc.getText(selectionOffset, 1).equals(" ") && !doc.getText(selectionOffset, 1).equals(">")) result = result + " "; doc.insertString(selectionOffset, result, javax.swing.text.SimpleAttributeSet.EMPTY); } catch (javax.swing.text.BadLocationException b) { // Okay if it doesn't work } ed.endCompoundUndoableEdit(); return; } }); insert.setPreferredSize(new Dimension(100, 25)); java.awt.GridLayout layoutOuter = new java.awt.GridLayout(3, 1); java.awt.FlowLayout layout = new java.awt.FlowLayout(FlowLayout.RIGHT); // rows, columns JPanel addPanel = new JPanel(); JPanel addPanelInner = new JPanel(); addPanel.setLayout(layoutOuter); addPanel.add(new JLabel("Search for a course, then choose one from the list below")); addPanelInner.setLayout(layout); addPanelInner.add(new JLabel("Search Keyword: ")); addPanelInner.add(searchText); addPanelInner.add(search); addPanel.add(addPanelInner); addPanelInner = new JPanel(); addPanelInner.setLayout(layout); addPanelInner.add(new JLabel("Narrow Search: ")); addPanelInner.add(possibleVals); addPanelInner.add(insert); addPanel.add(addPanelInner); JOptionPane.showMessageDialog((java.awt.Frame) ws.getParentFrame(), addPanel, label, JOptionPane.PLAIN_MESSAGE); } }); this.add(search); }
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 . ja v a2s. co m*/ 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 a v a 2 s . c om*/ 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:ee.ioc.cs.vsle.editor.Editor.java
/** * @param menu/* ww w . j a v a 2 s . c o m*/ */ private void makeSchemeMenu(JMenu menu) { menu.removeAll(); // Specification... JMenuItem menuItem = new JMenuItem(Menu.SPECIFICATION, KeyEvent.VK_S); menuItem.addActionListener(getActionListener()); menu.add(menuItem); //Extend menuItem = new JMenuItem(Menu.EXTEND_SPEC, KeyEvent.VK_E); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menu.add(new JSeparator()); // Run menuItem = new JMenuItem(Menu.RUN, KeyEvent.VK_R); menuItem.addActionListener(getActionListener()); menu.add(menuItem); //Propagate menuItem = new JCheckBoxMenuItem(Menu.PROPAGATE_VALUES, RuntimeProperties.isPropagateValues()); menuItem.addActionListener(getActionListener()); menu.add(menuItem); //Compute goal menuItem = new JCheckBoxMenuItem(Menu.COMPUTE_GOAL, RuntimeProperties.isComputeGoal()); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menu.add(new JSeparator()); // Values menuItem = new JMenuItem(Menu.SCHEME_VALUES, KeyEvent.VK_V); menuItem.addActionListener(getActionListener()); boolean enabled = getCurrentCanvas() != null && getCurrentCanvas().getLastProgramRunnerID() != 0; menuItem.setEnabled(enabled); if (!enabled) menuItem.setToolTipText("Run the scheme first"); menu.add(menuItem); menu.add(new JSeparator()); // Options menuItem = new JMenuItem(Menu.SCHEMEOPTIONS, KeyEvent.VK_O); menuItem.addActionListener(getActionListener()); menu.add(menuItem); }
From source file:com.googlecode.bpmn_simulator.gui.BPMNSimulatorFrame.java
private JMenu createMenuFile() { final JMenu menuFile = new JMenu(Messages.getString("Menu.file")); //$NON-NLS-1$ final JMenuItem menuFileOpen = new JMenuItem(Messages.getString("Menu.fileOpen")); //$NON-NLS-1$ menuFileOpen.setMnemonic(KeyEvent.VK_O); menuFileOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.ALT_MASK)); menuFileOpen.addActionListener(new ActionListener() { @Override/*from w w w . j a v a2s. co m*/ public void actionPerformed(final ActionEvent e) { openFile(); } }); menuFile.add(menuFileOpen); menuFile.add(menuFileRecent); final JMenuItem menuFileReload = new JMenuItem(Messages.getString("Menu.fileReload")); //$NON-NLS-1$ menuFileReload.setMnemonic(KeyEvent.VK_R); menuFileReload.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.ALT_MASK)); menuFileReload.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { reloadDefinition(); } }); menuFile.add(menuFileReload); final JMenuItem menuFileClose = new JMenuItem(Messages.getString("Menu.fileClose")); //$NON-NLS-1$ menuFileClose.setMnemonic(KeyEvent.VK_C); menuFileClose.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.ALT_MASK)); menuFileClose.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { closeSource(); } }); menuFile.add(menuFileClose); menuFile.addSeparator(); final JMenuItem menuFileProperties = new JMenuItem(Messages.getString("Menu.properties")); //$NON-NLS-1$ menuFileProperties.setMnemonic(KeyEvent.VK_P); menuFileProperties.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.ALT_MASK)); menuFileProperties.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { showPropertiesDialog(); } }); menuFile.add(menuFileProperties); menuFile.addSeparator(); final JMenuItem menuFileExport = createMenuFileExport(); menuFile.add(menuFileExport); menuFile.addSeparator(); final JMenuItem menuFilePreferences = new JMenuItem(Messages.getString("Menu.preferences")); //$NON-NLS-1$ menuFilePreferences.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { showPreferencesDialog(); } }); menuFile.add(menuFilePreferences); menuFile.addSeparator(); final JMenuItem menuFileExit = new JMenuItem(Messages.getString("Menu.exit")); //$NON-NLS-1$ menuFileExit.setMnemonic(KeyEvent.VK_E); menuFileExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_MASK)); menuFileExit.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { for (Frame frame : getFrames()) { if (frame.isActive()) { frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING)); } } } }); menuFile.add(menuFileExit); menuFile.addMenuListener(new MenuListener() { @Override public void menuSelected(final MenuEvent e) { menuFileReload.setEnabled(isSourceOpen() && currentSource.canReopen()); menuFileClose.setEnabled(isSourceOpen()); menuFileProperties.setEnabled(isDefinitionOpen()); menuFileExport.setEnabled(isDefinitionOpen()); } @Override public void menuDeselected(final MenuEvent e) { } @Override public void menuCanceled(final MenuEvent e) { } }); return menuFile; }
From source file:gdt.jgui.tool.JEntityEditor.java
/** * Get the context menu.// ww w . ja va 2 s . co m * @return the context menu. */ @Override public JMenu getContextMenu() { menu = new JMenu("Context"); menu.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { // System.out.println("EntityEditor:getConextMenu:menu selected"); if (editCellItem != null) menu.remove(editCellItem); if (deleteItemsItem != null) menu.remove(deleteItemsItem); if (copyItem != null) menu.remove(copyItem); if (pasteItem != null) menu.remove(pasteItem); if (cutItem != null) menu.remove(cutItem); if (hasEditingCell()) { //menu.addSeparator(); editCellItem = new JMenuItem("Edit item"); editCellItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String locator$ = getEditCellLocator(); if (locator$ != null) JConsoleHandler.execute(console, locator$); } }); menu.add(editCellItem); } if (hasSelectedRows()) { deleteItemsItem = new JMenuItem("Delete items"); deleteItemsItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(JEntityEditor.this, "Delete selected items ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { deleteRows(); } } }); menu.add(deleteItemsItem); copyItem = new JMenuItem("Copy"); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { element$ = null; content = getContent(true); } }); menu.add(copyItem); cutItem = new JMenuItem("Cut"); cutItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int i = tabbedPane.getSelectedIndex(); element$ = tabbedPane.getTitleAt(i); content = getContent(true); } }); menu.add(cutItem); } if (content != null) { pasteItem = new JMenuItem("Paste"); pasteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { pasteTable(content); int j = tabbedPane.getSelectedIndex(); if (element$ != null) { int cnt = tabbedPane.getComponentCount(); for (int i = 0; i < cnt; i++) { if (element$.equals(tabbedPane.getTitleAt(i))) { tabbedPane.setSelectedIndex(i); cutTable(content); tabbedPane.setSelectedIndex(j); } } } } }); menu.add(pasteItem); } } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); JMenuItem doneItem = new JMenuItem("Done"); doneItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { save(); console.back(); } }); menu.add(doneItem); JMenuItem cancelItem = new JMenuItem("Cancel"); cancelItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { console.back(); } }); menu.add(cancelItem); menu.addSeparator(); JMenuItem addItemItem = new JMenuItem("Add item"); addItemItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addRow(); } }); menu.add(addItemItem); JMenuItem addElementItem = new JMenuItem("Add element"); addElementItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String element$ = "new element"; //addElement(element$); String locator$ = getRenameElementLocator(element$); JConsoleHandler.execute(console, locator$); } }); menu.add(addElementItem); JMenuItem deleteElementItem = new JMenuItem("Delete element"); deleteElementItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(JEntityEditor.this, "Delete element ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { tabbedPane.remove(tabbedPane.getSelectedComponent()); } } }); menu.add(deleteElementItem); JMenuItem renameElementItem = new JMenuItem("Rename element"); renameElementItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int i = tabbedPane.getSelectedIndex(); String locator$ = getRenameElementLocator(tabbedPane.getTitleAt(i)); JConsoleHandler.execute(console, locator$); } }); menu.add(renameElementItem); menu.addSeparator(); if (hasEditingCell()) { editCellItem = new JMenuItem("Edit item"); editCellItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String locator$ = getEditCellLocator(); if (locator$ != null) JConsoleHandler.execute(console, locator$); } }); menu.add(editCellItem); } return menu; }
From source file:org.jax.maanova.test.gui.VolcanoPlotPanel.java
@SuppressWarnings("serial") private JMenuBar createMenu() { JMenuBar menuBar = new JMenuBar(); // the file menu JMenu fileMenu = new JMenu("File"); fileMenu.add(this.saveGraphImageAction); menuBar.add(fileMenu);//from ww w . j ava2s .c o m // the tools menu JMenu toolsMenu = new JMenu("Tools"); JMenuItem configureGraphItem = new JMenuItem("Configure Graph..."); configureGraphItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.chartConfigurationDialog.setVisible(true); } }); toolsMenu.add(configureGraphItem); toolsMenu.addSeparator(); toolsMenu.add(new AbstractAction("Clear Selections") { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.setSelectedIndices(new int[0]); } }); toolsMenu.addSeparator(); ButtonGroup dragButtonGroup = new ButtonGroup(); JCheckBoxMenuItem selectModeCheckBox = new JCheckBoxMenuItem("Drag Cursor to Select"); selectModeCheckBox.setSelected(true); this.dragToSelect = true; selectModeCheckBox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.dragToSelect = e.getStateChange() == ItemEvent.SELECTED; } }); dragButtonGroup.add(selectModeCheckBox); toolsMenu.add(selectModeCheckBox); JCheckBoxMenuItem zoomModeCheckBox = new JCheckBoxMenuItem("Drag Cursor to Zoom"); zoomModeCheckBox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.dragToZoom = e.getStateChange() == ItemEvent.SELECTED; } }); dragButtonGroup.add(zoomModeCheckBox); toolsMenu.add(zoomModeCheckBox); toolsMenu.addSeparator(); toolsMenu.add(new AbstractAction("Zoom Out") { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.autoRangeChart(); } }); toolsMenu.addSeparator(); JCheckBoxMenuItem showTooltipCheckbox = new JCheckBoxMenuItem("Show Info Popup for Nearest Point"); showTooltipCheckbox.setSelected(true); this.showTooltip = true; showTooltipCheckbox.addItemListener(new ItemListener() { /** * {@inheritDoc} */ public void itemStateChanged(ItemEvent e) { VolcanoPlotPanel.this.showTooltip = e.getStateChange() == ItemEvent.SELECTED; VolcanoPlotPanel.this.clearProbePopup(); } }); toolsMenu.add(showTooltipCheckbox); toolsMenu.addSeparator(); toolsMenu.add(this.displayTestResultsAction); toolsMenu.addSeparator(); toolsMenu.add(this.saveSelectedPointsMenuItem); JMenu selectPointsFromLisMenu = new JMenu("Select Points From Gene List"); List<String> geneListNames = this.maanovaTestResult.getParentExperiment().getGeneListNames(); if (geneListNames.isEmpty()) { JMenuItem noListsMenuItem = new JMenuItem("No Gene Lists Available"); noListsMenuItem.setEnabled(false); selectPointsFromLisMenu.add(noListsMenuItem); } else { for (final String geneListName : geneListNames) { JMenuItem currGeneListMenuItem = new JMenuItem( RUtilities.fromRIdentifierToReadableName(geneListName)); currGeneListMenuItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { VolcanoPlotPanel.this.selectedIndicesFromGeneList(geneListName); } }); selectPointsFromLisMenu.add(currGeneListMenuItem); } } toolsMenu.add(selectPointsFromLisMenu); menuBar.add(toolsMenu); // the help menu JMenu helpMenu = new JMenu("Help"); JMenuItem helpMenuItem = new JMenuItem("Help..."); Icon helpIcon = new ImageIcon(VolcanoPlotPanel.class.getResource("/images/action/help-16x16.png")); helpMenuItem.setIcon(helpIcon); helpMenuItem.addActionListener(new ActionListener() { /** * {@inheritDoc} */ public void actionPerformed(ActionEvent e) { Maanova.getInstance().showHelp("volcano-plot", VolcanoPlotPanel.this); } }); helpMenu.add(helpMenuItem); menuBar.add(helpMenu); return menuBar; }
From source file:ee.ioc.cs.vsle.editor.Editor.java
/** * @param menu//from ww w .j a v a2 s. c o m */ private void makeRecentSubMenu(JMenu menu) { menu.removeAll(); for (final Map.Entry<String, String> entry : RuntimeProperties.getRecentPackages().entrySet()) { JMenuItem menuItem = new JMenuItem(entry.getKey()); menuItem.setToolTipText(entry.getValue()); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openNewCanvasWithPackage(new File(entry.getValue())); } }); menu.add(menuItem); } }