Java Code Examples for javax.swing.JMenuBar#add()
The following examples show how to use
javax.swing.JMenuBar#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GUIFrame.java From jaamsim with Apache License 2.0 | 6 votes |
/** * Sets up the Control Panel's menu bar. */ private void initializeMenus() { // Set up the individual menus this.initializeFileMenu(); this.initializeEditMenu(); this.initializeToolsMenu(); this.initializeWindowMenu(); this.initializeOptionsMenu(); this.initializeUnitsMenu(); this.initializeHelpMenu(); // Add the individual menu to the main menu JMenuBar mainMenuBar = new JMenuBar(); mainMenuBar.add( fileMenu ); mainMenuBar.add( editMenu ); mainMenuBar.add( toolsMenu ); mainMenuBar.add( viewsMenu ); mainMenuBar.add( optionMenu ); mainMenuBar.add( unitsMenu ); mainMenuBar.add( helpMenu ); // Add main menu to the window setJMenuBar( mainMenuBar ); }
Example 2
Source File: ScreenMenuMemoryLeakTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private static void showUI() { sFrame = new JFrame(); sFrame.add(new JLabel("Some dummy content")); JMenuBar menuBar = new JMenuBar(); sMenu = new JMenu("Menu"); JMenuItem item = new JMenuItem("Item"); sMenu.add(item); sMenuItem = new WeakReference<>(item); menuBar.add(sMenu); sFrame.setJMenuBar(menuBar); sFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); sFrame.pack(); sFrame.setVisible(true); }
Example 3
Source File: MSMSLibrarySubmissionWindow.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
private void addMenu() { JMenuBar menu = new JMenuBar(); JMenu settings = new JMenu("Settings"); menu.add(settings); JFrame thisframe = this; // reset zoom JMenuItem resetZoom = new JMenuItem("reset zoom"); menu.add(resetZoom); resetZoom.addActionListener(e -> { if (group != null) group.resetZoom(); }); // JMenuItem setSize = new JMenuItem("chart size"); // menu.add(setSize); // setSize.addActionListener(e -> { // Dimension dim = SizeSelectDialog.getSizeInput(); // if (dim != null) // setChartSize(dim); // }); // addCheckBox(settings, "show legend", showLegend, e -> setShowLegend(((JCheckBoxMenuItem) e.getSource()).isSelected())); addCheckBox(settings, "show title", showTitle, e -> setShowTitle(((JCheckBoxMenuItem) e.getSource()).isSelected())); addCheckBox(settings, "show crosshair", showCrosshair, e -> setShowCrosshair(((JCheckBoxMenuItem) e.getSource()).isSelected()));; this.setJMenuBar(menu); }
Example 4
Source File: SwingSet3.java From beautyeye with Apache License 2.0 | 5 votes |
protected JMenuBar createMenuBar() { JMenuBar menubar = new JMenuBar(); menubar.setName("menubar"); // File menu JMenu fileMenu = new JMenu(); fileMenu.setName("file"); menubar.add(fileMenu); // File -> Quit if (!runningOnMac()) { JMenuItem quitItem = new JMenuItem(); quitItem.setName("quit"); quitItem.setAction(getAction("quit")); fileMenu.add(quitItem); } // View menu JMenu viewMenu = new JMenu(); viewMenu.setName("view"); // View -> Look and Feel viewMenu.add(createLookAndFeelMenu()); // View -> Source Code Visible sourceCodeCheckboxItem = new JCheckBoxMenuItem(); sourceCodeCheckboxItem.setSelected(isSourceCodeVisible()); sourceCodeCheckboxItem.setName("sourceCodeCheckboxItem"); sourceCodeCheckboxItem.addChangeListener(new SourceVisibilityChangeListener()); viewMenu.add(sourceCodeCheckboxItem); menubar.add(viewMenu); return menubar; }
Example 5
Source File: PreviewApplet.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
private void updateMenu( final JMenu[] menus ) { if ( menus != null && menus.length > 0 ) { final JMenuBar menuBar = new JMenuBar(); for ( int i = 0; i < menus.length; i++ ) { final JMenu menu = menus[i]; menuBar.add( menu ); } setJMenuBar( menuBar ); } else { setJMenuBar( null ); } }
Example 6
Source File: MenuBarProvider.java From lucene-solr with Apache License 2.0 | 5 votes |
public JMenuBar get() { JMenuBar menuBar = new JMenuBar(); menuBar.add(createFileMenu()); menuBar.add(createToolsMenu()); menuBar.add(createHelpMenu()); return menuBar; }
Example 7
Source File: MainFrame.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Creates the menu bar. * * @return the j menu bar */ private JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); JMenu optionsMenu = new JMenu("Options"); JMenuItem showInheritedFeatsItem = new JMenuItem("Show Inherited Features"); optionsMenu.add(showInheritedFeatsItem); menuBar.add(optionsMenu); return menuBar; }
Example 8
Source File: Editor.java From Cafebabe with GNU General Public License v3.0 | 5 votes |
private JMenuBar createMenu() { JMenuBar mb = new JMenuBar(); JMenu actions = new JMenu(Translations.get("Actions")); JMenuItem close = new JMenuItem(Translations.get("Close all")); close.addActionListener(l -> { pane.closeAll(); }); actions.add(close); mb.add(actions); return mb; }
Example 9
Source File: MisplacedBorder.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public void run() { final JMenuBar menubar = new JMenuBar(); menubar.add(new JMenu("")); menubar.add(new JMenu("")); final JFrame frame = new JFrame(); frame.setUndecorated(true); frame.setJMenuBar(menubar); frame.setSize(W / 3, H / 3); frame.setLocationRelativeTo(null); frame.setVisible(true); // draw menu bar using standard order. final BufferedImage bi1 = step1(menubar); // draw menu border on top of the menu bar, nothing should be changed. final BufferedImage bi2 = step2(menubar); frame.dispose(); for (int x = 0; x < W; ++x) { for (int y = 0; y < H; ++y) { if (bi1.getRGB(x, y) != bi2.getRGB(x, y)) { try { ImageIO.write(bi1, "png", new File("image1.png")); ImageIO.write(bi2, "png", new File("image2.png")); } catch (IOException e) { e.printStackTrace(); } throw new RuntimeException("Failed: wrong color"); } } } }
Example 10
Source File: bug8071705.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static JFrame createGUI() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("Some menu"); menuBar.add(menu); for (int i = 0; i < 10; i++) { menu.add(new JMenuItem("Some menu #" + i)); } JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(200, 200)); frame.setJMenuBar(menuBar); return frame; }
Example 11
Source File: MSMSLibrarySubmissionWindow.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
private void addMenu() { JMenuBar menu = new JMenuBar(); JMenu settings = new JMenu("Settings"); menu.add(settings); JFrame thisframe = this; // reset zoom JMenuItem resetZoom = new JMenuItem("reset zoom"); menu.add(resetZoom); resetZoom.addActionListener(e -> { if (group != null) group.resetZoom(); }); // JMenuItem setSize = new JMenuItem("chart size"); // menu.add(setSize); // setSize.addActionListener(e -> { // Dimension dim = SizeSelectDialog.getSizeInput(); // if (dim != null) // setChartSize(dim); // }); // addCheckBox(settings, "show legend", showLegend, e -> setShowLegend(((JCheckBoxMenuItem) e.getSource()).isSelected())); addCheckBox(settings, "show title", showTitle, e -> setShowTitle(((JCheckBoxMenuItem) e.getSource()).isSelected())); addCheckBox(settings, "show crosshair", showCrosshair, e -> setShowCrosshair(((JCheckBoxMenuItem) e.getSource()).isSelected()));; this.setJMenuBar(menu); }
Example 12
Source File: bug8071705.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static JFrame createGUI() { JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("Some menu"); menuBar.add(menu); for (int i = 0; i < 10; i++) { menu.add(new JMenuItem("Some menu #" + i)); } JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(200, 200)); frame.setJMenuBar(menuBar); return frame; }
Example 13
Source File: EditorRootPane.java From libGDX-Path-Editor with Apache License 2.0 | 5 votes |
private JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); menuBar.add(createProjectMenu()); menuBar.add(createAddScreenMenu()); menuBar.add(createAddBGMenu()); menuBar.add(createAddPathMenu()); return menuBar; }
Example 14
Source File: MainActivity.java From Raccoon with Apache License 2.0 | 4 votes |
/** * New GUI * * @param archive * the archive to display. This may be null. */ public MainActivity(Archive archive) { this.archive = archive; views = new JTabbedPane(); downloadList = new ListView(); JMenuBar bar = new JMenuBar(); JMenu file = new JMenu(Messages.getString("MainActivity.1")); //$NON-NLS-1$ file.setMnemonic(KeyStroke.getKeyStroke(Messages.getString("MainActivity.0")).getKeyCode()); //$NON-NLS-1$ quit = new JMenuItem( Messages.getString("MainActivity.2"), KeyStroke.getKeyStroke(Messages.getString("MainActivity.22")).getKeyCode()); //$NON-NLS-1$ //$NON-NLS-2$ quit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, Toolkit.getDefaultToolkit() .getMenuShortcutKeyMask())); open = new JMenuItem( Messages.getString("MainActivity.3"), KeyStroke.getKeyStroke(Messages.getString("MainActivity.23")).getKeyCode()); //$NON-NLS-1$ //$NON-NLS-2$ open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit() .getMenuShortcutKeyMask())); close = new JMenuItem( Messages.getString("MainActivity.4"), KeyStroke.getKeyStroke(Messages.getString("MainActivity.24")).getKeyCode()); //$NON-NLS-1$ //$NON-NLS-2$ close.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit.getDefaultToolkit() .getMenuShortcutKeyMask())); update = new JMenuItem( Messages.getString("MainActivity.5"), KeyStroke.getKeyStroke(Messages.getString("MainActivity.25")).getKeyCode()); //$NON-NLS-1$ //$NON-NLS-2$ update.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, Toolkit.getDefaultToolkit() .getMenuShortcutKeyMask())); update.setEnabled(false); newArchive = new JMenuItem( Messages.getString("MainActivity.29"), KeyStroke.getKeyStroke(Messages.getString("MainActivity.30")) //$NON-NLS-1$ //$NON-NLS-2$ .getKeyCode()); newArchive.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit() .getMenuShortcutKeyMask())); exportArchive = new JMenuItem( Messages.getString("MainActivity.33"), KeyStroke.getKeyStroke(Messages.getString("MainActivity.35")).getKeyCode()); //$NON-NLS-1$ //$NON-NLS-2$ importArchive = new JMenuItem( Messages.getString("MainActivity.36"), KeyStroke.getKeyStroke(Messages.getString("MainActivity.37")).getKeyCode()); //$NON-NLS-1$ //$NON-NLS-2$ Preferences prefs = Preferences.userNodeForPackage(getClass()); fetchIcons = new JRadioButtonMenuItem( Messages.getString("MainActivity.34"), prefs.getBoolean(FETCHICONS, true)); //$NON-NLS-1$ file.add(newArchive); file.add(open); file.add(new JSeparator()); file.add(importArchive); file.add(exportArchive); file.add(update); file.add(new JSeparator()); file.add(close); file.add(quit); bar.add(file); JMenu view = new JMenu(Messages.getString("MainActivity.6")); //$NON-NLS-1$ view.setMnemonic(KeyStroke.getKeyStroke(Messages.getString("MainActivity.15")).getKeyCode()); //$NON-NLS-1$ search = new JMenuItem( Messages.getString("MainActivity.7"), KeyStroke.getKeyStroke(Messages.getString("MainActivity.26")).getKeyCode()); //$NON-NLS-1$ //$NON-NLS-2$ search.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit() .getMenuShortcutKeyMask())); downloads = new JMenuItem( Messages.getString("MainActivity.8"), KeyStroke.getKeyStroke(Messages.getString("MainActivity.27")).getKeyCode()); //$NON-NLS-1$ //$NON-NLS-2$ downloads.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, Toolkit.getDefaultToolkit() .getMenuShortcutKeyMask())); view.add(search); view.add(downloads); view.add(new JSeparator()); view.add(fetchIcons); search.setEnabled(false); downloads.setEnabled(false); importArchive.setEnabled(false); exportArchive.setEnabled(false); bar.add(view); JMenu help = new JMenu(Messages.getString("MainActivity.9")); //$NON-NLS-1$ help.setMnemonic(KeyStroke.getKeyStroke(Messages.getString("MainActivity.21")).getKeyCode()); //$NON-NLS-1$ contents = new JMenuItem( Messages.getString("MainActivity.10"), KeyStroke.getKeyStroke(Messages.getString("MainActivity.28")).getKeyCode()); //$NON-NLS-1$ //$NON-NLS-2$ contents.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); help.add(contents); bar.add(help); setJMenuBar(bar); setContentPane(views); }
Example 15
Source File: DomGui.java From DominionSim with MIT License | 4 votes |
private JMenuBar createMenu() { JMenuBar bar = new JMenuBar(); JMenu fileMenu = new JMenu( "File" ); fileMenu.setMnemonic( 'f' ); JMenuItem loadPool = new JMenuItem( "Import Bots", 'I' ); loadPool.addActionListener( this ); loadPool.setActionCommand( "Load" ); fileMenu.add( loadPool ); JMenuItem saveDeck = new JMenuItem( "Export Bots", 'E' ); saveDeck.addActionListener( this ); saveDeck.setActionCommand( "Save" ); fileMenu.add( saveDeck ); fileMenu.insertSeparator( 2 ); JMenuItem exit = new JMenuItem( "Exit", 'X' ); exit.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent ae ) { shutDown(); } } ); fileMenu.add( exit ); bar.add( fileMenu ); JMenu devmodeMenu = new JMenu("Development"); JCheckBoxMenuItem devMode = new JCheckBoxMenuItem( "Development Mode" ); devMode.setSelected(DomEngine.developmentMode); devMode.addActionListener(this); devMode.setActionCommand("DevMode"); devmodeMenu.add(devMode); bar.add(devmodeMenu); JMenu helpMenu = new JMenu( "Help" ); helpMenu.setMnemonic( 'h' ); JMenuItem webHelp = new JMenuItem( "http://dominionsimulator.wordpress.com" ); webHelp.addActionListener( this ); webHelp.setActionCommand( "WebHelp" ); helpMenu.add( webHelp); helpMenu.insertSeparator( 2 ); JMenuItem about = new JMenuItem( "About", 't' ); about.addActionListener( this ); about.setActionCommand( "About" ); helpMenu.add( about ); bar.add( helpMenu ); return bar; }
Example 16
Source File: ActionsClass.java From RobotBuilder with BSD 3-Clause "New" or "Revised" License | 4 votes |
public JMenuBar getMenuBar() { JMenuBar menu = new JMenuBar(); exporters = getExporters(); JMenu fileMenu = new JMenu("File"); JMenuItem newItem = new JMenuItem(newAction); JMenuItem saveItem = new JMenuItem(saveAction); JMenuItem openItem = new JMenuItem(openAction); JMenuItem saveAsItem = new JMenuItem(saveAsAction); newItem.setAccelerator(KeyStroke.getKeyStroke("control N")); saveItem.setAccelerator(KeyStroke.getKeyStroke("control S")); saveAsItem.setAccelerator(KeyStroke.getKeyStroke("control shift S")); openItem.setAccelerator(KeyStroke.getKeyStroke("control O")); fileMenu.add(newItem); fileMenu.add(saveItem); fileMenu.add(saveAsItem); fileMenu.add(openItem); fileMenu.add(new JSeparator()); fileMenu.add(exitAction); menu.add(fileMenu); JMenu editMenu = new JMenu("Edit"); JMenuItem undoItem = new JMenuItem(undoAction); JMenuItem redoItem = new JMenuItem(redoAction); undoItem.setAccelerator(KeyStroke.getKeyStroke("control Z")); redoItem.setAccelerator(KeyStroke.getKeyStroke("control Y")); editMenu.add(undoItem); editMenu.add(redoItem); menu.add(editMenu); JMenu viewMenu = new JMenu("View"); viewMenu.add(togglePalettViewAction); menu.add(viewMenu); JMenu exportMenu = new JMenu("Export"); exportMenu.add(verifyAction); exportMenu.add(new JSeparator()); exporters.stream().forEach(exportMenu::add); menu.add(exportMenu); JMenu helpMenu = new JMenu("Help"); helpMenu.add(gettingStartedAction); helpMenu.add(aboutAction); menu.add(helpMenu); return menu; }
Example 17
Source File: HistogramWindow.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
public HistogramWindow(ParameterSet parameters) { super(""); PeakList peakList = parameters.getParameter(HistogramParameters.peakList).getValue().getMatchingPeakLists()[0]; this.setTitle("Histogram of " + peakList.getName()); RawDataFile rawDataFiles[] = parameters.getParameter(HistogramParameters.dataFiles).getValue(); HistogramDataType dataType = parameters.getParameter(HistogramParameters.dataRange).getType(); int numOfBins = parameters.getParameter(HistogramParameters.numOfBins).getValue(); Range<Double> range = parameters.getParameter(HistogramParameters.dataRange).getValue(); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setBackground(Color.white); // Creates plot and toolbar histogram = new HistogramChart(); Border one = BorderFactory.createEtchedBorder(EtchedBorder.RAISED); Border two = BorderFactory.createEmptyBorder(5, 5, 5, 5); JPanel pnlPlot = new JPanel(new BorderLayout()); pnlPlot.setBorder(BorderFactory.createCompoundBorder(one, two)); pnlPlot.setBackground(Color.white); pnlPlot.add(histogram, BorderLayout.CENTER); add(pnlPlot, BorderLayout.CENTER); // Add the Windows menu JMenuBar menuBar = new JMenuBar(); menuBar.add(new WindowsMenu()); setJMenuBar(menuBar); pack(); // get the window settings parameter ParameterSet paramSet = MZmineCore.getConfiguration().getModuleParameters(HistogramVisualizerModule.class); WindowSettingsParameter settings = paramSet.getParameter(HistogramParameters.windowSettings); // update the window and listen for changes settings.applySettingsToWindow(this); this.addComponentListener(settings); if (peakList != null) { HistogramPlotDataset dataSet = new HistogramPlotDataset(peakList, rawDataFiles, numOfBins, dataType, range); histogram.addDataset(dataSet, dataType); } }
Example 18
Source File: HopActions.java From constellation with Apache License 2.0 | 4 votes |
public HopActions() { panel = new JPanel(); panel.setLayout(new BorderLayout()); menuBar = new JMenuBar(); menuBar.setOpaque(true); menu = new JMenu(); menu.setIcon(HOP_OUT_ONE_ICON); menu.setToolTipText("Hop Controls"); menu.setEnabled(false); final JMenuItem hopOutHalfItem = new JMenuItem("Hop Out Half"); hopOutHalfItem.setIcon(HOP_OUT_HALF_ICON); hopOutHalfItem.setActionCommand(HOP_OUT_HALF_ACTION); hopOutHalfItem.addActionListener(HopActions.this); menu.add(hopOutHalfItem); final JMenuItem hopOutOneItem = new JMenuItem("Hop Out One"); hopOutOneItem.setIcon(HOP_OUT_ONE_ICON); hopOutOneItem.setActionCommand(HOP_OUT_ONE_ACTION); hopOutOneItem.addActionListener(HopActions.this); menu.add(hopOutOneItem); final JMenuItem hopOutFullItem = new JMenuItem("Hop Out Full"); hopOutFullItem.setIcon(HOP_OUT_FULL_ICON); hopOutFullItem.setActionCommand(HOP_OUT_FULL_ACTION); hopOutFullItem.addActionListener(HopActions.this); menu.add(hopOutFullItem); final JPanel directionPanel = new JPanel(); directionPanel.setLayout(new BoxLayout(directionPanel, BoxLayout.Y_AXIS)); directionPanel.setBorder(new TitledBorder("Direction")); outgoing = new JCheckBox("Outgoing", true); outgoing.setToolTipText("Hop Along Outgoing Transactions"); directionPanel.add(outgoing); incoming = new JCheckBox("Incoming", true); incoming.setToolTipText("Hop Along Incoming Transactions"); directionPanel.add(incoming); undirected = new JCheckBox("Undirected", true); undirected.setToolTipText("Hop Along Undirected Transactions"); directionPanel.add(undirected); final JPanel optionsPanel = new JPanel(); optionsPanel.setBorder(new EmptyBorder(10, 0, 0, 0)); optionsPanel.setLayout(new BorderLayout()); optionsPanel.add(directionPanel, BorderLayout.CENTER); menu.add(optionsPanel); menuBar.add(menu); panel.add(menuBar, BorderLayout.CENTER); GraphManager.getDefault().addGraphManagerListener(HopActions.this); }
Example 19
Source File: DatFileViewer.java From settlers-remake with MIT License | 4 votes |
private JMenuBar createMenu() { JMenu openMenu = new JMenu("Open"); JMenuItem openDirItem = new JMenuItem("GFX Folder"); openMenu.add(openDirItem); JMenu exportMenu = new JMenu("Export Images"); JMenuItem exportThis = new JMenuItem("from this file"); JMenuItem exportAll = new JMenuItem("from all files"); exportMenu.add(exportThis); exportMenu.add(exportAll); JMenu showMenu = new JMenu("Show"); JMenuItem showSettlers = new JMenuItem("Settlers"); JMenuItem showGui = new JMenuItem("GUI"); JMenuItem showLandscape = new JMenuItem("Landscape"); showMenu.add(showSettlers); showMenu.add(showGui); showMenu.add(showLandscape); openDirItem.addActionListener((e) -> { JFileChooser openDirDlg = new JFileChooser(); openDirDlg.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (openDirDlg.showDialog(null, null) == JFileChooser.APPROVE_OPTION) { gfxDirectory = new File(openDirDlg.getSelectedFile().getAbsolutePath()); FileUtils.iterateChildren(gfxDirectory, (currentFile) -> { String fileName = currentFile.getName(); if (currentFile.isFile() && fileName.endsWith(".dat")) { listItems.addElement(currentFile.getName()); } }); } }); exportThis.addActionListener((e) -> onExportSelectedFile()); exportAll.addActionListener((e) -> onExportAllFiles()); showSettlers.addActionListener((e) -> { glCanvas.currentSet = ImageSet.SETTLERS; glCanvas.invalidate(); }); showGui.addActionListener((e) -> { glCanvas.currentSet = ImageSet.GUI; glCanvas.invalidate(); }); showLandscape.addActionListener((e) -> { glCanvas.currentSet = ImageSet.LANDTILES; glCanvas.invalidate(); }); JMenuBar bar = new JMenuBar(); bar.add(openMenu); bar.add(exportMenu); bar.add(showMenu); return bar; }
Example 20
Source File: MarvinEditor.java From marvinproject with GNU Lesser General Public License v3.0 | votes |
/** * Creates the menubar */ private void loadMenuBar() { menuBar = new JMenuBar(); menuHandler = new MenuHandler(); jmnFile = new JMenu("File"); jmnFile.setMnemonic('F'); menuBar.add(jmnFile); jmnEdit = new JMenu("Edit"); jmnEdit.setMnemonic('E'); menuBar.add(jmnEdit); // Load filter jmnFilters = new JMenu("Filters"); jmnFilters.setMnemonic('f'); jmnAnalyses = new JMenu("Analyse"); jmnAnalyses.setMnemonic('n'); loadPluginMenu("filters", jmnFilters, new FilterMenuItemHandler()); loadPluginMenu("analyses", jmnAnalyses, new FilterMenuItemHandler()); menuBar.add(jmnFilters); menuBar.add(jmnAnalyses); jmnHistory = new JMenu("History"); jmnHistory.setMnemonic('H'); jmiShowHistory = new JMenuItem("Show history"); jmiShowHistory.setIcon(new ImageIcon(ICONS_APPLICATION_PATH+"history.png")); jmiShowHistory.setMnemonic('S'); jmiShowHistory.addActionListener(menuHandler); jmnHistory.add(jmiShowHistory); // Menu Item New jmiNew = new JMenuItem("New"); jmiNew.setIcon(new ImageIcon(ICONS_APPLICATION_PATH+"newFile.png")); jmiNew.setMnemonic('N'); jmiNew.addActionListener(menuHandler); jmnFile.add(jmiNew); // Menu Item Open jmiOpen = new JMenuItem("Open"); jmiOpen.setIcon(new ImageIcon(ICONS_APPLICATION_PATH+"open.png")); jmiOpen.setMnemonic('O'); jmiOpen.addActionListener(menuHandler); jmnFile.add(jmiOpen); // Menu Item Save jmiSave = new JMenuItem("Save"); jmiSave.setIcon(new ImageIcon(ICONS_APPLICATION_PATH+"save.png")); jmiSave.setMnemonic('S'); jmiSave.addActionListener(menuHandler); jmnFile.add(jmiSave); // Menu Item Save As jmiSaveAs = new JMenuItem("Save As..."); jmiSaveAs.setIcon(new ImageIcon(ICONS_APPLICATION_PATH+"saveas.png")); jmiSaveAs.setMnemonic('a'); jmiSaveAs.addActionListener(menuHandler); jmnFile.add(jmiSaveAs); // Menu Item Close jmiExit= new JMenuItem("Exit"); jmiExit.setIcon(new ImageIcon(ICONS_APPLICATION_PATH+"exit.png")); jmiExit.setMnemonic('E'); jmiExit.addActionListener(menuHandler); jmnFile.add(jmiExit); // Menu Item Reset jmiReset = new JMenuItem("Reset"); jmiReset.setIcon(new ImageIcon(ICONS_APPLICATION_PATH+"reset.png")); jmiReset.setMnemonic('R'); jmiReset.addActionListener(menuHandler); // Menu Item Edit jmnEdit.add(jmiReset); // Menu Item Help jmnHelp = new JMenu("Help"); jmnHelp.setMnemonic('H'); // Menu Item About jmiAbout = new JMenuItem("About"); jmiAbout.setIcon(new ImageIcon(ICONS_APPLICATION_PATH+"about.png")); jmiAbout.setMnemonic('A'); jmiAbout.addActionListener(menuHandler); menuBar.add(jmnHistory); jmnHelp.add(jmiAbout); menuBar.add(jmnHelp); /* TODO JAVADOC IS NOT FINISHED YET * jmnHelp.add(jmiJavadoc); */ add(menuBar, BorderLayout.NORTH); }