List of usage examples for javax.swing JMenu JMenu
public JMenu(Action a)
Action
supplied. From source file:de.peterspan.csv2db.AppWindow.java
private void initialize() { frame = new JFrame(); frame.setIconImage(Icons.IC_APPLICATION_X_LARGE.getImage()); AppWindow._frame = frame;/*from w w w. ja va 2s. c o m*/ frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { if (reallyExit() == JOptionPane.YES_OPTION) { SingleInstance.release(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } } }); frame.setTitle(Messages.getString("AppWindow.0") + " " + Messages.getString("AppWindow.version.code")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ frame.setLocationRelativeTo(null); JMenuBar menuBar = new JMenuBar(); frame.setJMenuBar(menuBar); JMenu mnFile = new JMenu(Messages.getString("AppWindow.1")); //$NON-NLS-1$ menuBar.add(mnFile); JMenuItem mntmExit = new JMenuItem(Messages.getString("AppWindow.3")); //$NON-NLS-1$ mntmExit.setIcon(Icons.IC_LOGOUT_SMALL); mntmExit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { WindowEvent wev = new WindowEvent(frame, WindowEvent.WINDOW_CLOSING); Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(wev); } }); mnFile.add(mntmExit); JMenu mnEdit = new JMenu(Messages.getString("AppWindow.4")); //$NON-NLS-1$ menuBar.add(mnEdit); JMenuItem mntmOptions = new JMenuItem(Messages.getString("AppWindow.5")); //$NON-NLS-1$ mntmOptions.setIcon(Icons.IC_PREFERENCES_SYSTEM_SMALL); mntmOptions.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // new OptionsDialog(frame); } }); mnEdit.add(mntmOptions); JMenu mnHelp = new JMenu(Messages.getString("AppWindow.6")); //$NON-NLS-1$ menuBar.add(mnHelp); JMenuItem mntmAbout = new JMenuItem(Messages.getString("AppWindow.7")); //$NON-NLS-1$ mntmAbout.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { try { new AboutDialog(frame); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); mnHelp.add(mntmAbout); createContent(); DialogUtil.getInstance().setMainFrame(frame); }
From source file:gdt.jgui.tool.JTextEncrypter.java
/** * Get context menu./*from w w w .ja v a 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) { menu.removeAll(); JMenuItem doneItem = new JMenuItem("Done"); doneItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (requesterResponseLocator$ != null) { try { byte[] ba = Base64.decodeBase64(requesterResponseLocator$); String responseLocator$ = new String(ba, "UTF-8"); text$ = textArea.getText(); responseLocator$ = Locator.append(responseLocator$, JTextEditor.TEXT, text$); //System.out.println("TextEditor:done:response locator="+responseLocator$); JConsoleHandler.execute(console, responseLocator$); } catch (Exception ee) { Logger.getLogger(JTextEncrypter.class.getName()).severe(ee.toString()); } } else 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); char[] master = passwordField.getPassword(); // System.out.println("Textencoder:context menu:master="+master.length); if (master.length > 6) { menu.addSeparator(); JMenuItem encryptItem = new JMenuItem("Encrypt"); encryptItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { char[] master = passwordField.getPassword(); DesEncrypter desEncrypter = new DesEncrypter(master); String encrypted$ = desEncrypter.encrypt(textArea.getText()); textArea.setText(encrypted$); } }); menu.add(encryptItem); JMenuItem decryptItem = new JMenuItem("Decrypt"); decryptItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { char[] master = passwordField.getPassword(); DesEncrypter desEncrypter = new DesEncrypter(master); String decrypted$ = desEncrypter.decrypt(textArea.getText()); if (decrypted$ != null && decrypted$.length() > 0) textArea.setText(decrypted$); } }); menu.add(decryptItem); } } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); return menu; }
From source file:net.adamjak.thomas.graph.application.gui.ResultsWidnow.java
private JMenuBar createJMenuBar() { this.jMenuBar = new JMenuBar(); // Menu File/*from ww w . ja v a2 s . c o m*/ JMenu jmFile = new JMenu("File"); JMenuItem jmiFileSaveResults = new JMenuItem("Save results"); jmiFileSaveResults.setAccelerator(GuiAccelerators.CTRL_S); jmiFileSaveResults.addActionListener(new AlJmiFileSaveResults()); jmFile.add(jmiFileSaveResults); //jmFile.addSeparator(); this.jMenuBar.add(jmFile); return this.jMenuBar; }
From source file:de.tud.kom.p2psim.impl.skynet.visualization.SkyNetVisualization.java
private SkyNetVisualization() { super("Metric-Visualization"); createLookAndFeel();// ww w . ja v a2 s. c om displayedMetrics = new HashMap<String, MetricsPlot>(); setLayout(new GridLayout(1, 1)); addWindowListener(this); graphix = new JPanel(new GridBagLayout()); graphix.setLayout(new BoxLayout(graphix, BoxLayout.PAGE_AXIS)); mb = new JMenuBar(); JScrollPane scroller = new JScrollPane(graphix, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); // calculating the size of the application-window as well as of all // components, that depend on the size of the window Toolkit kit = Toolkit.getDefaultToolkit(); int appWidth = kit.getScreenSize().width * 3 / 4; int appHeight = kit.getScreenSize().height * 3 / 4; scroller.setPreferredSize(new Dimension(appWidth, appHeight)); getContentPane().add(scroller); maxPlotsPerRow = 1; while ((maxPlotsPerRow + 1) * PLOT_WIDTH < appWidth) { maxPlotsPerRow++; } log.warn("Creating the visualization..."); mb.add(new JMenu("File")); JMenu met = new JMenu("Available Metrics"); met.setEnabled(false); mb.add(met); setJMenuBar(mb); }
From source file:com.projity.pm.graphic.network.NetworkPopupMenu.java
/** * Because the styles may change, rebuild the menu each time * *//*from w ww . j ava2 s .c o m*/ protected void init() { removeAll(); final JMenu bars = new JMenu(Messages.getString("Network.Popup.barStylesMenu")); CollectionUtils.forAllDo(interactor.getGraph().getBarStyles().getRows(), new Closure() { public void execute(Object arg0) { BarStyle barStyle = (BarStyle) arg0; BarMenuAction menuAction = new BarMenuAction(barStyle); bars.add(menuAction); } }); add(bars); }
From source file:DragColorTextFieldDemo.java
public JMenuBar createMenuBar() { JMenuItem menuItem = null;//w w w.j a va 2s . c om JMenuBar menuBar = new JMenuBar(); JMenu mainMenu = new JMenu("Edit"); mainMenu.setMnemonic(KeyEvent.VK_E); menuItem = new JMenuItem(new DefaultEditorKit.CutAction()); menuItem.setText("Cut"); menuItem.setMnemonic(KeyEvent.VK_T); mainMenu.add(menuItem); menuItem = new JMenuItem(new DefaultEditorKit.CopyAction()); menuItem.setText("Copy"); menuItem.setMnemonic(KeyEvent.VK_C); mainMenu.add(menuItem); menuItem = new JMenuItem(new DefaultEditorKit.PasteAction()); menuItem.setText("Paste"); menuItem.setMnemonic(KeyEvent.VK_P); mainMenu.add(menuItem); menuBar.add(mainMenu); return menuBar; }
From source file:de.genvlin.plugins.jfreechart.JFreeChartPluginImpl.java
public void sendRequest(RequestEvent ri) { if (ri.getActionContextReason() == PluginPool.SELECTED_COLS) { selected = (VectorInterface[]) ((GTablePanel) ri.getSource()).getSelectedVectors(); JMenu menu = new JMenu(getName()); JMenuItem item = new JMenuItem(getMenuName()); item.setActionCommand(getMenuName()); menu.add(item);/* w w w.jav a 2 s . co m*/ item.addActionListener(this); item = new JMenuItem(LINEAR_REG); item.setActionCommand(LINEAR_REG); menu.add(item); item.addActionListener(this); ((JPopupMenu) ri.getObject()).add(menu); } }
From source file:net.sf.housekeeper.swing.MainFrame.java
/** * Builds the menus./* w w w . j ava 2s .c o m*/ * * @return The created menu bar. Is not null. */ private JMenuBar buildMenuBar() { final JMenuBar menuBar = new JMenuBar(); //File Menu final String fileMenuLabel = LocalisationManager.INSTANCE.getText("gui.menu.file"); final JMenu menuFile = new JMenu(fileMenuLabel); menuBar.add(menuFile); menuFile.add(new JMenuItem(new LoadDataAction())); menuFile.add(new JMenuItem(new SaveDataAction())); menuFile.addSeparator(); menuFile.add(new JMenuItem(new ExitAction())); //Help Menu final String helpMenuString = LocalisationManager.INSTANCE.getText("gui.menu.help"); final JMenu menuHelp = new JMenu(helpMenuString); menuBar.add(Box.createHorizontalGlue()); menuBar.add(menuHelp); menuHelp.add(new JMenuItem(new AboutDialogAction())); return menuBar; }
From source file:net.erdfelt.android.sdkfido.ui.SdkFidoFrame.java
private JMenu createFileMenu() { JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('f'); JMenuItem fileExit = new JMenuItem("Exit"); fileExit.setMnemonic('x'); fileExit.setActionCommand("exit"); fileExit.addActionListener(actionMapper); fileMenu.add(fileExit);/*from w w w . j av a 2 s.c o m*/ return fileMenu; }
From source file:de.atomfrede.tools.evalutation.ui.AppWindow.java
/** * Initialize the contents of the frame. */// w ww . j av a2s .co m private void initialize() { log.info("Plant Evaluator started"); frame = new JFrame(); frame.setIconImage(Icons.IC_APPLICATION_X_LARGE.getImage()); AppWindow._frame = frame; frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { if (reallyExit() == JOptionPane.YES_OPTION) { SingleInstance.release(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } } }); frame.setTitle(Messages.getString("AppWindow.0") + " " + Messages.getString("AppWindow.version.code")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ frame.setLocationRelativeTo(null); JMenuBar menuBar = new JMenuBar(); frame.setJMenuBar(menuBar); JMenu mnFile = new JMenu(Messages.getString("AppWindow.1")); //$NON-NLS-1$ menuBar.add(mnFile); JMenuItem mntmExit = new JMenuItem(Messages.getString("AppWindow.3")); //$NON-NLS-1$ mntmExit.setIcon(Icons.IC_LOGOUT_SMALL); mntmExit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { WindowEvent wev = new WindowEvent(frame, WindowEvent.WINDOW_CLOSING); Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(wev); } }); mnFile.add(mntmExit); JMenu mnEdit = new JMenu(Messages.getString("AppWindow.4")); //$NON-NLS-1$ menuBar.add(mnEdit); JMenuItem mntmOptions = new JMenuItem(Messages.getString("AppWindow.5")); //$NON-NLS-1$ mntmOptions.setIcon(Icons.IC_PREFERENCES_SYSTEM_SMALL); mntmOptions.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new OptionsDialog(frame); } }); mnEdit.add(mntmOptions); JMenu mnTools = new JMenu(Messages.getString("AppWindow.mnTools.text")); //$NON-NLS-1$ menuBar.add(mnTools); JMenuItem mntmPostprocessing = new JMenuItem(Messages.getString("AppWindow.mntmPostprocessing.text")); //$NON-NLS-1$ mntmPostprocessing.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub } }); mnTools.add(mntmPostprocessing); JMenuItem mntmPlot = new JMenuItem(Messages.getString("AppWindow.mntmPlot.text")); //$NON-NLS-1$ mntmPlot.setIcon(Icons.IC_TOOL_PLOT_SMALL); mntmPlot.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { DialogUtil.getInstance().showPlotTypeSelection(); } }); mnTools.add(mntmPlot); JMenu mnHelp = new JMenu(Messages.getString("AppWindow.6")); //$NON-NLS-1$ menuBar.add(mnHelp); JMenuItem mntmAbout = new JMenuItem(Messages.getString("AppWindow.7")); //$NON-NLS-1$ mntmAbout.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { try { new AboutDialog(frame); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); mnHelp.add(mntmAbout); createContent(); DialogUtil.getInstance().setMainFrame(frame); }