List of usage examples for javax.swing JMenu JMenu
public JMenu(Action a)
Action
supplied. From source file:be.fedict.eid.tsl.tool.TslTool.java
private void initNewMenu(JMenu fileMenu) { JMenu newMenu = new JMenu("New"); newMenu.setMnemonic(KeyEvent.VK_N); fileMenu.add(newMenu);//from w w w. ja va 2 s . c om JMenu belgiumMenu = new JMenu("Belgium"); newMenu.add(belgiumMenu); JMenu _2010BelgiumMenu = new JMenu("2010"); belgiumMenu.add(_2010BelgiumMenu); JMenuItem _2010_T1_BelgiumMenuItem = addActionMenuItem("Trimester 1", KeyEvent.VK_1, "TSL-BE-2010-T1", _2010BelgiumMenu, true); _2010BelgiumMenu.add(_2010_T1_BelgiumMenuItem); JMenuItem _2010_T2_BelgiumMenuItem = addActionMenuItem("Trimester 2", KeyEvent.VK_2, "TSL-BE-2010-T2", _2010BelgiumMenu, true); _2010BelgiumMenu.add(_2010_T2_BelgiumMenuItem); JMenuItem _2010_T3_BelgiumMenuItem = addActionMenuItem("Trimester 3", KeyEvent.VK_3, "TSL-BE-2010-T3", _2010BelgiumMenu, true); _2010BelgiumMenu.add(_2010_T3_BelgiumMenuItem); JMenu _2011BelgiumMenu = new JMenu("2011"); belgiumMenu.add(_2011BelgiumMenu); addActionMenuItem("Trimester 1", KeyEvent.VK_1, "TSL-BE-2011-T1", _2011BelgiumMenu, true); addActionMenuItem("Trimester 2", KeyEvent.VK_2, "TSL-BE-2011-T2", _2011BelgiumMenu, true); addActionMenuItem("Trimester 3", KeyEvent.VK_3, "TSL-BE-2011-T3", _2011BelgiumMenu, true); JMenu _2012BelgiumMenu = new JMenu("2012"); belgiumMenu.add(_2012BelgiumMenu); addActionMenuItem("Trimester 1", KeyEvent.VK_1, "TSL-BE-2012-T1", _2012BelgiumMenu, true); addActionMenuItem("Trimester 2", KeyEvent.VK_2, "TSL-BE-2012-T2", _2012BelgiumMenu, true); addActionMenuItem("Trimester 3", KeyEvent.VK_3, "TSL-BE-2012-T3", _2012BelgiumMenu, true); JMenu _2013BelgiumMenu = new JMenu("2013"); belgiumMenu.add(_2013BelgiumMenu); addActionMenuItem("Trimester 1", KeyEvent.VK_1, "TSL-BE-2013-T1", _2013BelgiumMenu, true); addActionMenuItem("Trimester 2", KeyEvent.VK_2, "TSL-BE-2013-T2", _2013BelgiumMenu, true); addActionMenuItem("Trimester 3", KeyEvent.VK_3, "TSL-BE-2013-T3", _2013BelgiumMenu, true); JMenu _2014BelgiumMenu = new JMenu("2014"); belgiumMenu.add(_2014BelgiumMenu); addActionMenuItem("Trimester 1", KeyEvent.VK_1, "TSL-BE-2014-T1", _2014BelgiumMenu, true); addActionMenuItem("Trimester 2", KeyEvent.VK_1, "TSL-BE-2014-T2", _2014BelgiumMenu, true); addActionMenuItem("Trimester 3", KeyEvent.VK_1, "TSL-BE-2014-T3", _2014BelgiumMenu, true); JMenu _2015BelgiumMenu = new JMenu("2015"); belgiumMenu.add(_2015BelgiumMenu); addActionMenuItem("Trimester 1", KeyEvent.VK_1, "TSL-BE-2015-T1", _2015BelgiumMenu, true); addActionMenuItem("Trimester 2", KeyEvent.VK_1, "TSL-BE-2015-T2", _2015BelgiumMenu, true); addActionMenuItem("Trimester 3", KeyEvent.VK_1, "TSL-BE-2015-T3", _2015BelgiumMenu, true); }
From source file:com.simplexrepaginator.RepaginateFrame.java
protected JMenuBar createMenuBar() { JMenuBar mb = new JMenuBar(); JMenu m;/* w ww . jav a2 s.c o m*/ m = new JMenu("File"); m.add(new AbstractAction("Select Input") { @Override public void actionPerformed(ActionEvent e) { input.doClick(); } }); m.add(new AbstractAction("Select Output") { @Override public void actionPerformed(ActionEvent e) { output.doClick(); } }); m.add(new UpdateCheckerAction()); m.add(new AbstractAction("Exit") { @Override public void actionPerformed(ActionEvent arg0) { dispose(); } }); mb.add(m); m = new JMenu("Help"); m.add(new AbstractAction("Website") { @Override public void actionPerformed(ActionEvent e) { try { URL url = new URL("http://www.simplexrepaginator.com/"); Desktop.getDesktop().browse(url.toURI()); } catch (IOException ioe) { } catch (URISyntaxException urise) { } } }); m.add(new AbstractAction("About") { @Override public void actionPerformed(ActionEvent e) { String license; try { license = IOUtils.toString(RepaginateFrame.class.getResource("LICENSE.txt")); } catch (IOException ioe) { license = "An error occured reading the license file:\n" + ioe; } JOptionPane.showMessageDialog(RepaginateFrame.this, license); } }); mb.add(m); return mb; }
From source file:edu.synth.SynthHelper.java
private void menu() { menuBar = new JMenuBar(); setJMenuBar(menuBar);// w w w . j a va 2s.c om mnFile = new JMenu("File"); menuBar.add(mnFile); mntmOpenWorkspace = new JMenuItem("Open Workspace..."); mntmOpenWorkspace.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new Thread(new Runnable() { @Override public void run() { clear(); String path = SyntHelper.getInstance().openDialogFileChooser(state.getWorkspacePath(), true, "Choose Workspace", "Choose", null); try { state.setWorkspacePath(path); } catch (IOException e) { Messager.publish("Set Workspace", e); } initSettings(); setValues(); } }).start(); } }); mnFile.add(mntmOpenWorkspace); mntmApplyChanges = new JMenuItem("Save Changes..."); mntmApplyChanges.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { new Thread(new Runnable() { @Override public void run() { try { state.saveSettings(); } catch (IOException e) { Messager.publish("Save Settings Files", e); } } }).start(); } }); mnFile.add(mntmApplyChanges); mntmExportConfFiles = new JMenuItem("Export Settings Files to Workspace..."); mntmExportConfFiles.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { new Thread(new Runnable() { @Override public void run() { try { state.saveSettings(); } catch (IOException e) { Messager.publish("Save Settings Files", e); } if (!state.getWorkspacePath().isEmpty()) try { state.copySettingsFilesToWorkspace(); } catch (IOException e) { Messager.publish("Export Settings Files to Workspace", e); } else Messager.publish("Export Settings Files to Workspace", "Files have not been copied. Workspace has not been selected!"); } }).start(); } }); mnFile.add(mntmExportConfFiles); mnFile.add(new JSeparator()); mntmExit = new JMenuItem("Exit"); mntmExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.exit(0); } }); mnFile.add(mntmExit); mnOperations = new JMenu("Operations"); menuBar.add(mnOperations); mntmViewObs = new JMenuItem("View Observed Data (1.obs)"); mntmViewObs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { new Thread(new Runnable() { @Override public void run() { try { new DataViewWindow("Observed Data Viewer", new File(Constants.OBS_DATA)); } catch (IOException e) { Messager.publish("Observed Data Viewer error", e); } } }).start(); } }); mnOperations.add(mntmViewObs); mnOperations.add(new JSeparator()); mntmRunSynth = new JMenuItem("Run Synth"); mntmRunSynth.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { new Thread(new ExecuteSynthConvThread()).start(); } }); mnOperations.add(mntmRunSynth); mntmRunSynthForObs = new JMenuItem("Run Synth for Observed Data"); mntmRunSynthForObs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { final Thread main = new Thread(new ExecuteSynthConvDivThread()); main.start(); new Thread(new Runnable() { @Override public void run() { while (main.isAlive()) { } ; try { new SyntHelperChartWindow("Result of synthesis and dividing"); } catch (IOException e) { Messager.publish("Charting result error", e); } } }).start(); } }); mnOperations.add(mntmRunSynthForObs); mnHelp = new JMenu("Help"); menuBar.add(mnHelp); mntmLogWindow = new JMenuItem("Log Window"); mntmLogWindow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { LogPublisher.getInstance().openWindow(); } }); mnHelp.add(mntmLogWindow); mnHelp.add(new JSeparator()); mntmAbout = new JMenuItem("About SYNTHelper"); mnHelp.add(mntmAbout); mntmHelp = new JMenuItem("Help Content"); mnHelp.add(mntmHelp); }
From source file:de.hstsoft.sdeep.view.MainWindow.java
private void createUI() { mapView = new MapView(); getContentPane().add(mapView, BorderLayout.CENTER); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar);/*from ww w. j a v a2s . c o m*/ JMenu mnFile = new JMenu("File"); menuBar.add(mnFile); JMenuItem mntmOpenSaveGame = new JMenuItem("Open Savegame"); mntmOpenSaveGame.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { openFileChooser(); } }); mnFile.add(mntmOpenSaveGame); mnFile.addSeparator(); JMenuItem mntmExit = new JMenuItem("Exit"); mntmExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); mnFile.add(mntmExit); JMenu mnView = new JMenu("View"); menuBar.add(mnView); final JCheckBoxMenuItem menuItemShowinfo = new JCheckBoxMenuItem("ShowInfo"); menuItemShowinfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean showInfo = menuItemShowinfo.isSelected(); mapView.setShowInfo(showInfo); } }); menuItemShowinfo.setSelected(mapView.isShowInfo()); mnView.add(menuItemShowinfo); final JCheckBoxMenuItem menuItemShowgrid = new JCheckBoxMenuItem("ShowGrid"); menuItemShowgrid.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean showGrid = menuItemShowgrid.isSelected(); mapView.setShowGrid(showGrid); } }); menuItemShowgrid.setSelected(mapView.isShowGrid()); mnView.add(menuItemShowgrid); final JCheckBoxMenuItem menuItemNotes = new JCheckBoxMenuItem("ShowNotes"); menuItemNotes.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean showNotes = menuItemNotes.isSelected(); mapView.setShowNotes(showNotes); } }); menuItemNotes.setSelected(mapView.isShowNotes()); mnView.add(menuItemNotes); final JCheckBoxMenuItem menuItemAnimals = new JCheckBoxMenuItem("ShowAnimals"); menuItemAnimals.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean showAnimals = menuItemAnimals.isSelected(); mapView.setShowAnimals(showAnimals); } }); menuItemAnimals.setSelected(mapView.isShowAnimals()); mnView.add(menuItemAnimals); mnView.addSeparator(); menuItemFileWatcher = new JCheckBoxMenuItem("Auto refresh"); menuItemFileWatcher.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean enabled = menuItemFileWatcher.isSelected(); toggleAutoRefresh(enabled); } }); mnView.add(menuItemFileWatcher); mnView.addSeparator(); JMenuItem menuItemResetView = new JMenuItem("Reset view"); menuItemResetView.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { mapView.resetView(); } }); mnView.add(menuItemResetView); JMenu mnInfo = new JMenu("Info"); menuBar.add(mnInfo); JMenuItem mntmInfo = new JMenuItem("About"); mntmInfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showInfo(); } }); mnInfo.add(mntmInfo); }
From source file:be.agiv.security.demo.Main.java
private void addMenuBar() { JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar);/*from w ww . j a va 2 s . c om*/ JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); this.preferencesMenuItem = new JMenuItem("Preferences"); fileMenu.add(this.preferencesMenuItem); this.preferencesMenuItem.addActionListener(this); fileMenu.addSeparator(); this.exitMenuItem = new JMenuItem("Exit"); fileMenu.add(this.exitMenuItem); this.exitMenuItem.addActionListener(this); JMenu ipStsMenu = new JMenu("IP-STS"); menuBar.add(ipStsMenu); this.ipStsIssueMenuItem = new JMenuItem("Issue token"); ipStsMenu.add(this.ipStsIssueMenuItem); this.ipStsIssueMenuItem.addActionListener(this); this.ipStsViewMenuItem = new JMenuItem("View token"); ipStsMenu.add(this.ipStsViewMenuItem); this.ipStsViewMenuItem.addActionListener(this); this.ipStsViewMenuItem.setEnabled(false); JMenu rStsMenu = new JMenu("R-STS"); menuBar.add(rStsMenu); this.rStsIssueMenuItem = new JMenuItem("Issue token"); rStsMenu.add(this.rStsIssueMenuItem); this.rStsIssueMenuItem.addActionListener(this); this.rStsIssueMenuItem.setEnabled(false); this.rStsViewMenuItem = new JMenuItem("View token"); rStsMenu.add(this.rStsViewMenuItem); this.rStsViewMenuItem.addActionListener(this); this.rStsViewMenuItem.setEnabled(false); JMenu secConvMenu = new JMenu("Secure Conversation"); menuBar.add(secConvMenu); this.secConvIssueMenuItem = new JMenuItem("Issue token"); secConvMenu.add(this.secConvIssueMenuItem); this.secConvIssueMenuItem.addActionListener(this); this.secConvIssueMenuItem.setEnabled(false); this.secConvViewMenuItem = new JMenuItem("View token"); secConvMenu.add(this.secConvViewMenuItem); this.secConvViewMenuItem.addActionListener(this); this.secConvViewMenuItem.setEnabled(false); this.secConvCancelMenuItem = new JMenuItem("Cancel token"); secConvMenu.add(this.secConvCancelMenuItem); this.secConvCancelMenuItem.addActionListener(this); this.secConvCancelMenuItem.setEnabled(false); JMenu servicesMenu = new JMenu("Services"); menuBar.add(servicesMenu); this.claimsAwareServiceMenuItem = new JMenuItem("Claims aware service"); servicesMenu.add(this.claimsAwareServiceMenuItem); this.claimsAwareServiceMenuItem.addActionListener(this); menuBar.add(Box.createHorizontalGlue()); JMenu helpMenu = new JMenu("Help"); menuBar.add(helpMenu); this.aboutMenuItem = new JMenuItem("About"); helpMenu.add(this.aboutMenuItem); this.aboutMenuItem.addActionListener(this); }
From source file:ee.ioc.cs.vsle.editor.Editor.java
/** * Build menu.//from ww w . j av a 2s . c o m */ public void makeMenu() { JMenuItem menuItem; JMenu menu; JMenu submenu; menuBar = new JMenuBar(); setJMenuBar(menuBar); menu = new JMenu(Menu.MENU_FILE); menu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem(Menu.NEW_SCHEME, KeyEvent.VK_N); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Menu.LOAD_SCHEME, KeyEvent.VK_O); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); menu.add(menuItem); menuItem = new JMenuItem(Menu.RELOAD_SCHEME, KeyEvent.VK_R); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK)); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Menu.SAVE_SCHEME, KeyEvent.VK_S); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)); menu.add(menuItem); menuItem = new JMenuItem(Menu.SAVE_SCHEME_AS); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Menu.DELETE_SCHEME, KeyEvent.VK_D); menuItem.addActionListener(getActionListener()); menu.add(menuItem); submenu = new JMenu(Menu.EXPORT_MENU); menu.add(submenu); //submenu.setMnemonic( KeyEvent.VK_E ); SchemeExporter.makeSchemeExportMenu(submenu, getActionListener()); // Export window graphics submenu.add(GraphicsExporter.getExportMenu()); menu.addSeparator(); menuItem = new JMenuItem(Menu.PRINT, KeyEvent.VK_P); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK)); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Menu.EXIT, KeyEvent.VK_X); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuBar.add(menu); menu = new JMenu(Menu.MENU_EDIT); menu.setMnemonic(KeyEvent.VK_E); menu.add(undoAction); menu.add(redoAction); menu.add(cloneAction); menuItem = new JMenuItem(Menu.SCHEME_FIND, KeyEvent.VK_F); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK)); menu.add(menuItem); menuItem = new JMenuItem(Menu.SELECT_ALL, KeyEvent.VK_A); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK)); menu.add(menuItem); menuItem = new JMenuItem(Menu.CLEAR_ALL, KeyEvent.VK_C); menuItem.addActionListener(getActionListener()); menu.add(menuItem); final JCheckBoxMenuItem painterEnabled = new JCheckBoxMenuItem(Menu.CLASSPAINTER, true); painterEnabled.addActionListener(getActionListener()); menu.add(painterEnabled); menu.getPopupMenu().addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuCanceled(PopupMenuEvent e) { // ignore } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // ignore } @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { Canvas canvas = Editor.getInstance().getCurrentCanvas(); if (canvas == null || !canvas.getPackage().hasPainters()) { painterEnabled.setVisible(false); } else { painterEnabled.setVisible(true); painterEnabled.setSelected(canvas.isEnableClassPainter()); } } }); menuBar.add(menu); menu = new JMenu(Menu.MENU_VIEW); menu.setMnemonic(KeyEvent.VK_V); gridCheckBox = new JCheckBoxMenuItem(Menu.GRID, RuntimeProperties.isShowGrid()); gridCheckBox.setMnemonic('G'); gridCheckBox.addActionListener(getActionListener()); menu.add(gridCheckBox); ctrlCheckBox = new JCheckBoxMenuItem(Menu.CONTROL_PANEL, RuntimeProperties.isShowControls()); ctrlCheckBox.setMnemonic('C'); ctrlCheckBox.addActionListener(getActionListener()); menu.add(ctrlCheckBox); showPortCheckBox = new JCheckBoxMenuItem(Menu.SHOW_PORTS, true); showPortCheckBox.addActionListener(getActionListener()); menu.add(showPortCheckBox); showObjectNamesCheckBox = new JCheckBoxMenuItem(Menu.SHOW_NAMES, false); showObjectNamesCheckBox.addActionListener(getActionListener()); menu.add(showObjectNamesCheckBox); //sync View with current canvas menu.getPopupMenu().addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { Canvas canvas; if ((canvas = getCurrentCanvas()) == null) return; gridCheckBox.setSelected(canvas.isGridVisible()); ctrlCheckBox.setSelected(canvas.isCtrlPanelVisible()); showPortCheckBox.setSelected(canvas.isDrawPorts()); showObjectNamesCheckBox.setSelected(canvas.isShowObjectNames()); } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // ignore } @Override public void popupMenuCanceled(PopupMenuEvent e) { // ignore } }); menuBar.add(menu); menu = new JMenu(Menu.MENU_PACKAGE); menu.setMnemonic(KeyEvent.VK_P); menuItem = new JMenuItem(Menu.LOAD, KeyEvent.VK_L); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuItem = new JMenuItem(Menu.RELOAD, KeyEvent.VK_R); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuItem = new JMenuItem(Menu.INFO, KeyEvent.VK_I); menuItem.addActionListener(getActionListener()); menu.add(menuItem); if (Desktop.isDesktopSupported()) { menuItem = new JMenuItem(Menu.BROWSE_PACKAGE, KeyEvent.VK_B); menuItem.addActionListener(getActionListener()); menu.add(menuItem); } menuItem = new JMenuItem(Menu.CLOSE, KeyEvent.VK_C); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuItem = new JMenuItem(Menu.CLOSE_ALL); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuBar.add(menu); menu.add(new JSeparator()); final JMenu submenuRecent = new JMenu(Menu.RECENT); submenuRecent.getPopupMenu().addPopupMenuListener(new PopupMenuListener() { final JMenuItem empty = new JMenuItem("Empty"); @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { makeRecentSubMenu(submenuRecent); if (submenuRecent.getMenuComponentCount() == 0) { submenuRecent.add(empty); empty.setEnabled(false); } else { if (!((submenuRecent.getMenuComponentCount() == 1) && (submenuRecent.getPopupMenu().getComponentIndex(empty) >= -1))) { submenuRecent.remove(empty); } } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // ignore } @Override public void popupMenuCanceled(PopupMenuEvent e) { // ignore } }); menu.add(submenuRecent); final JMenu menuScheme = new JMenu(Menu.MENU_SCHEME); menuScheme.setMnemonic(KeyEvent.VK_S); makeSchemeMenu(menuScheme); menuScheme.getPopupMenu().addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { makeSchemeMenu(menuScheme); } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // ignore } @Override public void popupMenuCanceled(PopupMenuEvent e) { // ignore } }); /* * menuItem = new JMenuItem("Planner"); * menuItem.addActionListener(aListener); menuScheme.add(menuItem); * menuItem = new JMenuItem("Plan, compile, run"); * menuItem.setActionCommand("Run"); * menuItem.addActionListener(aListener); menuScheme.add(menuItem); */ // menuScheme.setMnemonic(KeyEvent.VK_A); menuBar.add(menuScheme); menu = new JMenu(Menu.MENU_OPTIONS); menu.setMnemonic(KeyEvent.VK_O); menuItem = new JMenuItem(Menu.SETTINGS, KeyEvent.VK_S); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, ActionEvent.CTRL_MASK)); menu.add(menuItem); menuItem = new JMenuItem(Menu.FONTS); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuItem = new JMenuItem(Menu.SAVE_SETTINGS); menuItem.addActionListener(getActionListener()); menu.add(menuItem); submenu = new JMenu(Menu.MENU_LAF); submenu.setMnemonic(KeyEvent.VK_L); Look.getInstance().createMenuItems(submenu); menu.add(submenu); menuBar.add(menu); makeToolsMenu(menuBar); menu = new JMenu(Menu.MENU_HELP); menu.setMnemonic(KeyEvent.VK_H); menuBar.add(menu); menuItem = new JMenuItem(Menu.DOCS, KeyEvent.VK_D); menuItem.addActionListener(getActionListener()); menu.add(menuItem); }
From source file:org.kepler.plotting.Plot.java
private void initializeToggleMenu() { if (toggleMenu == null) { toggleMenu = new JMenu("Toggle line"); }/* www .java2s .c o m*/ if (!added) { chartPanel.getPopupMenu().add(toggleMenu); added = true; } }
From source file:jhplot.HPlotChart.java
/** * Create canvas that keeps JFreeChart panel. * /*from w ww . jav a 2 s. c om*/ * @param jchart * chart of JFreeChart. * @param xsize * size in x direction * @param ysize * size in y direction */ public HPlotChart(JFreeChart jchart, int xsize, int ysize) { this.xsize = xsize; this.ysize = ysize; frame = new JFrame("HPloatChart"); chart = jchart; cp = new ChartPanel(chart); cp.setPreferredSize(new Dimension(xsize, ysize)); cp.setBackground(DEFAULT_BG_COLOR); cp.setLayout(new BorderLayout()); cp.setDomainZoomable(true); cp.setRangeZoomable(true); chart.setAntiAlias(true); chart.setBorderPaint(DEFAULT_BG_COLOR); chart.setBackgroundPaint(DEFAULT_BG_COLOR); chart.setBorderVisible(false); org.jfree.chart.plot.Plot pp = (org.jfree.chart.plot.Plot) chart.getPlot(); pp.setBackgroundPaint(DEFAULT_BG_COLOR); setTheme("LEGACY_THEME"); frame.add(cp); JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); JMenuItem item1 = new JMenuItem("Export"); item1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { exportDialog(); } }); JMenuItem item2 = new JMenuItem("Close"); item2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { close(); } }); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); menu.add(item1); menu.add(item2); bar.add(menu); frame.setJMenuBar(bar); frame.setPreferredSize(new Dimension(xsize, ysize)); }
From source file:br.ufrgs.enq.jcosmo.ui.COSMOSACDialog.java
public COSMOSACDialog() { super("JCOSMO Simple"); setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new BorderLayout()); db = COSMOSACDataBase.getInstance(); COSMOSAC models[] = new COSMOSAC[5]; models[0] = new COSMOSAC(); models[1] = new COSMOPAC(); models[2] = new COSMOSAC_SVP(); models[3] = new COSMOSAC_G(); models[4] = new PCMSAC(); modelBox = new JComboBox(models); modelBox.addActionListener(this); JPanel north = new JPanel(new GridLayout(0, 2)); add(north, BorderLayout.NORTH); JPanel northAba1 = new JPanel(new GridLayout(0, 4)); JPanel northAba2 = new JPanel(new GridLayout(0, 2)); //Where the GUI is created: JMenuBar menuBar;//w w w. ja v a2 s. c o m JMenu file, help; JMenuItem menuItem; //Create the menu bar. menuBar = new JMenuBar(); // the file menu file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); menuBar.add(file); menuItem = new JMenuItem("Quit", KeyEvent.VK_Q); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK)); menuItem.setActionCommand(QUIT); menuItem.addActionListener(this); file.add(menuItem); // the help menu help = new JMenu("Help"); file.setMnemonic(KeyEvent.VK_H); menuBar.add(help); menuItem = new JMenuItem("About", KeyEvent.VK_A); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); menuItem.setActionCommand(ABOUT); menuItem.addActionListener(this); help.add(menuItem); setJMenuBar(menuBar); listModel = new DefaultListModel(); list = new JList(listModel); list.setBorder(BorderFactory.createTitledBorder("compounds")); list.setVisibleRowCount(2); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane listScrollPane = new JScrollPane(list); JButton addButton = new JButton("Add"); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new AddCompoundDialog(COSMOSACDialog.this); } }); removeButton = new JButton("Remove"); removeButton.addActionListener(this); visibRemove(false); JButton calcButton = new JButton("Calculate"); calcButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rebuildChart(); rebuildSigmaProfiles(); } }); JButton refreshButton = new JButton("Refresh"); refreshButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rebuildSigmaProfiles(); } }); ignoreSGButton = new JCheckBox("Ignore SG"); ignoreSGButton.setToolTipText("Toogles the ignore flag for the Staverman-Guggenheim term"); ignoreSGButton.addActionListener(this); JPanel but = new JPanel(new GridLayout(0, 1)); but.add(addButton, BorderLayout.EAST); but.add(removeButton, BorderLayout.EAST); but.add(modelBox); north.add(listScrollPane); north.add(but); northAba1.add(new JLabel("Temperature [K]")); northAba1.add(temperature = new JTextField(10)); temperature.setText("298"); northAba1.add(new JLabel("Sigma HB")); northAba1.add(sigmaHB = new JTextField(10)); northAba1.add(new JLabel("Sigma HB2")); northAba1.add(sigmaHB2 = new JTextField(10)); northAba1.add(new JLabel("Sigma HB3")); northAba1.add(sigmaHB3 = new JTextField(10)); northAba1.add(new JLabel("Charge HB")); northAba1.add(chargeHB = new JTextField(10)); northAba1.add(new JLabel("Sigma Disp")); northAba1.add(sigmaDisp = new JTextField(10)); northAba1.add(new JLabel("Charge Disp")); northAba1.add(chargeDisp = new JTextField(10)); northAba1.add(new JLabel("Beta")); northAba1.add(beta = new JTextField(10)); northAba1.add(new JLabel("fpol")); northAba1.add(fpol = new JTextField(10)); northAba1.add(new JLabel("Anorm")); northAba1.add(anorm = new JTextField(10)); northAba1.add(ignoreSGButton); northAba1.add(calcButton); northAba2.add(new JLabel("")); northAba2.add(refreshButton); // chart = new JLineChart(); // add(chart, BorderLayout.CENTER); // chart.setTitle("Gamma Plot"); // chart.setSubtitle(""); // chart.setXAxisLabel("Mole Fraction, x_1"); // chart.setYAxisLabel("ln gamma, gE/RT"); // chart.setSource(getTitle()); // chart.setLegendPosition(LegendPosition.BOTTOM); // chart.setShapesVisible(true); JFreeChart chart = ChartFactory.createXYLineChart(null, "Mole Fraction, x_1", "ln gamma, gE/RT", null, PlotOrientation.VERTICAL, true, true, false); plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setAutoRange(false); plot.getDomainAxis().setRange(new Range(0.0, 1.0)); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer(); r.setUseFillPaint(true); r.setBaseFillPaint(Color.white); r.setBaseShapesVisible(true); JFreeChart sigmaProfileChart = ChartFactory.createXYLineChart(null, "sigma", "P^x", null, PlotOrientation.VERTICAL, true, true, false); sigmaProfilePlot = sigmaProfileChart.getXYPlot(); sigmaProfilePlot.getDomainAxis().setAutoRange(false); sigmaProfilePlot.getDomainAxis().setRange(new Range(-0.025, 0.025)); // sigmaProfilePlot.setBackgroundPaint(Color.lightGray); // sigmaProfilePlot.setDomainGridlinePaint(Color.white); // sigmaProfilePlot.setRangeGridlinePaint(Color.white); JFreeChart chartSegGamma = ChartFactory.createXYLineChart(null, "sigma", "Segment Gamma", null, PlotOrientation.VERTICAL, true, true, false); plotSegGamma = (XYPlot) chartSegGamma.getPlot(); JPanel south = new JPanel(); south.setLayout(new FlowLayout()); south.add(new JLabel("<html>ln γ<sup>∞</sup><sub>1</sub>:</html>")); south.add(lnGammaInf1Label = new JLabel()); south.add(new JLabel("<html>ln γ<sup>∞</sup><sub>2</sub>:</html>")); south.add(lnGammaInf2Label = new JLabel()); south.add(Box.createHorizontalStrut(20)); south.add(new JLabel("<html>γ<sup>∞</sup><sub>1</sub>:</html>")); south.add(gammaInf1Label = new JLabel()); south.add(new JLabel("<html>γ<sup>∞</sup><sub>2</sub>:</html>")); south.add(gammaInf2Label = new JLabel()); JPanel aba1 = new JPanel(new BorderLayout()); aba1.add(northAba1, BorderLayout.NORTH); JPanel chartsPanel = new JPanel(new GridLayout(0, 2)); aba1.add(chartsPanel, BorderLayout.CENTER); chartsPanel.add(new ChartPanel(chart)); chartsPanel.add(new ChartPanel(chartSegGamma)); aba1.add(south, BorderLayout.SOUTH); JPanel aba2 = new JPanel(new BorderLayout()); aba2.add(northAba2, BorderLayout.NORTH); aba2.add(chartPanel = new ChartPanel(sigmaProfileChart), BorderLayout.CENTER); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("gamma", aba1); tabbedPane.addTab("sigma", aba2); add(tabbedPane, BorderLayout.CENTER); // cosmosac.setAEffPrime(6.596176570595075); // cosmosac.setCoord(11.614599507917934); // cosmosac.setVnorm(56.36966406129967); // cosmosac.setAnorm(41.56058649432742); // cosmosac.setCHB(65330.19484947528); // cosmosac.setSigmaHB(0.008292411048046008); //Display the window. setSize(800, 600); setLocationRelativeTo(null); modelBox.setSelectedIndex(0); setVisible(true); // test for a mixture // addList("WATER"); // addList("H3O+1"); // addList("OH-1"); // addList("CL-1"); // addList("OXYGEN"); // addList("sec-butylamine"); // addList("hydrogen-fluoride"); // addList("ACETONE"); // addList("METHANOL"); // addList("ACETONE.opt"); // addList("METHANOL.opt"); // addList("METHYL-ETHYL-KETONE"); // addList("ETHANOL"); // addList("N-HEPTANE"); // addList("PROPIONIC-ACID"); // addList("EMIM"); // addList("NTF2"); // addList("DCA"); // addList("N-OCTANE"); addList("ETHYLENE CARBONATE"); addList("BENZENE"); addList("TOLUENE"); removeButton.setEnabled(true); }
From source file:components.TabComponentsDemo.java
private void initMenu() { JMenuBar menuBar = new JMenuBar(); //create Options menu tabComponentsItem = new JCheckBoxMenuItem("Use TabComponents", true); tabComponentsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.ALT_MASK)); tabComponentsItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { for (int i = 0; i < pane.getTabCount(); i++) { if (tabComponentsItem.isSelected()) { initTabComponent(i); } else { pane.setTabComponentAt(i, null); }/*from www. ja v a 2 s.com*/ } } }); scrollLayoutItem = new JCheckBoxMenuItem("Set ScrollLayout"); scrollLayoutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.ALT_MASK)); scrollLayoutItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (pane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT) { pane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); } else { pane.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT); } } }); JMenuItem resetItem = new JMenuItem("Reset JTabbedPane"); resetItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.ALT_MASK)); resetItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { runTest(); } }); JMenu optionsMenu = new JMenu("Options"); optionsMenu.add(tabComponentsItem); optionsMenu.add(scrollLayoutItem); optionsMenu.add(resetItem); menuBar.add(optionsMenu); setJMenuBar(menuBar); }