List of usage examples for javax.swing JMenu addSeparator
public void addSeparator()
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 av a 2s.c om 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:edu.ku.brc.specify.tools.StrLocalizerApp.java
/** * @param frame//w w w .j a v a 2 s . c om */ public void addMenuBar(final JFrame frame) { this.frame = frame; JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu(getResourceString("FILE")); JMenuItem chooseFileItem = new JMenuItem(getResourceString("StrLocalizerApp.ChooseFileMenu")); fileMenu.add(chooseFileItem); chooseFileItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doChooseFile(); } }); JMenuItem saveItem = new JMenuItem(getResourceString("SAVE")); fileMenu.add(saveItem); saveItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doSave(); } }); fileMenu.addSeparator(); JMenuItem chooseDirMenu = new JMenuItem(getResourceString("StrLocalizerApp.CreateNewLocaleMenu")); fileMenu.add(chooseDirMenu); chooseDirMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doCreateNewLocale(false); } }); JMenuItem newLocaleItem = new JMenuItem(getResourceString("StrLocalizerApp.ChooseLocaleMenu")); fileMenu.add(newLocaleItem); newLocaleItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String fullLanguage = doChooseExistingLocalization(); if (fullLanguage != null) { init(fullLanguage); } } }); /* JMenuItem mneuItem = new JMenuItem(getResourceString("Check For old Localizations")); fileMenu.add(mneuItem); mneuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) {new if (baseDir == null) { getDefaultPath(); } if (baseDir != null) { File englishDir = new File(rootDir.getAbsolutePath() + File.separator + "en"); LocalizerSearchHelper helper = new LocalizerSearchHelper(englishDir, "file-index"); helper.findOldL10NKeys(getFileNames()); } } });*/ // JMenuItem openItem = new JMenuItem("Open"); // fileMenu.add(openItem); // // openItem.addActionListener(new ActionListener() { // // /* (non-Javadoc) // * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) // */ // @Override // public void actionPerformed(ActionEvent e) // { // doOpen(); // } // }); if (!UIHelper.isMacOS()) { fileMenu.addSeparator(); JMenuItem exitMenu = new JMenuItem(getResourceString("EXIT")); exitMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doExit(checkForChanges()); } }); fileMenu.add(exitMenu); } menuBar.add(fileMenu); JMenu transMenu = new JMenu(getResourceString("StrLocalizerApp.Translate")); menuBar.add(transMenu); startTransMenuItem = new JMenuItem(getResourceString("StrLocalizerApp.Start")); transMenu.add(startTransMenuItem); startTransMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { translateNewItems(); } }); stopTransMenuItem = new JMenuItem(getResourceString("Stop")); transMenu.add(stopTransMenuItem); stopTransMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { contTrans.set(false); } }); stopTransMenuItem.setEnabled(false); frame.setJMenuBar(menuBar); setTopWindow(frame); register(FRAME, frame); }
From source file:edu.ku.brc.ui.UIHelper.java
/** * @param app//from w w w .ja v a 2 s. c o m * @param isPlatformSpecific * @param includeCutCopyPaste * @return the menubar */ public static JMenuBar getBasicMenuBar(final boolean includeCutCopyPaste) { JMenuBar menuBar = new JMenuBar(); String title = "FileMenu"; String mneu = "FileMneu"; JMenu fileMenu = createLocalizedMenu(menuBar, title, mneu); if (oSType != OSTYPE.MacOSX) { fileMenu.addSeparator(); fileMenu.add(createMenu(getResourceString("ExitMenu"), getResourceString("ExitAccl").charAt(0), getResourceString("ExitMneu"))); } else { //new MacOSAppHandler((AppIFace)app); } if (includeCutCopyPaste) { title = "EditMenu"; mneu = "EditMneu"; JMenu editMenu = createLocalizedMenu(menuBar, title, mneu); editMenu.add(createMenu(getResourceString("CutMenu"), getResourceString("CutAccl").charAt(0), getResourceString("CutMneu"))); editMenu.add(createMenu(getResourceString("CopyMenu"), VK_C, getResourceString("CopyMneu"))); editMenu.add(createMenu(getResourceString("PasteMenu"), VK_V, getResourceString("PasteMneu"))); } return menuBar; }
From source file:edu.ku.brc.specify.tools.l10nios.StrLocalizerAppForiOS.java
/** * @param frame//w ww . j ava 2 s. com */ public void addMenuBar(final JFrame frame) { this.frame = frame; JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu(getResourceString("FILE")); JMenuItem chooseFileItem = new JMenuItem(getResourceString("StrLocalizerApp.ChooseFileMenu")); fileMenu.add(chooseFileItem); chooseFileItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doChooseFile(); } }); JMenuItem saveItem = new JMenuItem(getResourceString("SAVE")); fileMenu.add(saveItem); saveItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doSave(); } }); if (!UIHelper.isMacOS()) { fileMenu.addSeparator(); JMenuItem exitMenu = new JMenuItem(getResourceString("EXIT")); exitMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doExit(checkForChanges()); } }); fileMenu.add(exitMenu); } menuBar.add(fileMenu); JMenu scanMenu = new JMenu(getResourceString("Scan")); menuBar.add(scanMenu); scanMI = new JMenuItem(getResourceString("Source Code")); scanMenu.add(scanMI); scanMI.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scanSources(); } }); JMenu transMenu = new JMenu(getResourceString("StrLocalizerApp.Translate")); menuBar.add(transMenu); startTransMenuItem = new JMenuItem(getResourceString("StrLocalizerApp.Start")); transMenu.add(startTransMenuItem); startTransMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { translateNewItems(); } }); transMenu.setVisible(false); stopTransMenuItem = new JMenuItem(getResourceString("Stop")); transMenu.add(stopTransMenuItem); stopTransMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { contTrans.set(false); } }); stopTransMenuItem.setEnabled(false); frame.setJMenuBar(menuBar); setTopWindow(frame); register(FRAME, frame); }
From source file:com.isti.traceview.common.TraceViewChartPanel.java
/** * Creates a popup menu for the panel.// w w w. j a va2s . c o m * * @param properties * include a menu item for the chart property editor. * @param save * include a menu item for saving the chart. * @param print * include a menu item for printing the chart. * @param zoom * include menu items for zooming. * @return The popup menu. */ protected JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) { JPopupMenu result = new JPopupMenu("Chart:"); boolean separator = false; if (properties) { JMenuItem propertiesItem = new JMenuItem(localizationResources.getString("Properties...")); propertiesItem.setActionCommand(PROPERTIES_COMMAND); propertiesItem.addActionListener(this); result.add(propertiesItem); separator = true; } if (save) { if (separator) { result.addSeparator(); separator = false; } JMenuItem saveItem = new JMenuItem(localizationResources.getString("Save_as...")); saveItem.setActionCommand(SAVE_COMMAND); saveItem.addActionListener(this); result.add(saveItem); separator = true; } if (print) { if (separator) { result.addSeparator(); separator = false; } JMenuItem printItem = new JMenuItem(localizationResources.getString("Print...")); printItem.setActionCommand(PRINT_COMMAND); printItem.addActionListener(this); result.add(printItem); separator = true; } if (zoom) { if (separator) { result.addSeparator(); separator = false; } JMenu zoomInMenu = new JMenu(localizationResources.getString("Zoom_In")); this.zoomInBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes")); this.zoomInBothMenuItem.setActionCommand(ZOOM_IN_BOTH_COMMAND); this.zoomInBothMenuItem.addActionListener(this); zoomInMenu.add(this.zoomInBothMenuItem); zoomInMenu.addSeparator(); this.zoomInDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis")); this.zoomInDomainMenuItem.setActionCommand(ZOOM_IN_DOMAIN_COMMAND); this.zoomInDomainMenuItem.addActionListener(this); zoomInMenu.add(this.zoomInDomainMenuItem); this.zoomInRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis")); this.zoomInRangeMenuItem.setActionCommand(ZOOM_IN_RANGE_COMMAND); this.zoomInRangeMenuItem.addActionListener(this); zoomInMenu.add(this.zoomInRangeMenuItem); result.add(zoomInMenu); JMenu zoomOutMenu = new JMenu(localizationResources.getString("Zoom_Out")); this.zoomOutBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes")); this.zoomOutBothMenuItem.setActionCommand(ZOOM_OUT_BOTH_COMMAND); this.zoomOutBothMenuItem.addActionListener(this); zoomOutMenu.add(this.zoomOutBothMenuItem); zoomOutMenu.addSeparator(); this.zoomOutDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis")); this.zoomOutDomainMenuItem.setActionCommand(ZOOM_OUT_DOMAIN_COMMAND); this.zoomOutDomainMenuItem.addActionListener(this); zoomOutMenu.add(this.zoomOutDomainMenuItem); this.zoomOutRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis")); this.zoomOutRangeMenuItem.setActionCommand(ZOOM_OUT_RANGE_COMMAND); this.zoomOutRangeMenuItem.addActionListener(this); zoomOutMenu.add(this.zoomOutRangeMenuItem); result.add(zoomOutMenu); JMenu autoRangeMenu = new JMenu(localizationResources.getString("Auto_Range")); this.zoomResetBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes")); this.zoomResetBothMenuItem.setActionCommand(ZOOM_RESET_BOTH_COMMAND); this.zoomResetBothMenuItem.addActionListener(this); autoRangeMenu.add(this.zoomResetBothMenuItem); autoRangeMenu.addSeparator(); this.zoomResetDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis")); this.zoomResetDomainMenuItem.setActionCommand(ZOOM_RESET_DOMAIN_COMMAND); this.zoomResetDomainMenuItem.addActionListener(this); autoRangeMenu.add(this.zoomResetDomainMenuItem); this.zoomResetRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis")); this.zoomResetRangeMenuItem.setActionCommand(ZOOM_RESET_RANGE_COMMAND); this.zoomResetRangeMenuItem.addActionListener(this); autoRangeMenu.add(this.zoomResetRangeMenuItem); result.addSeparator(); result.add(autoRangeMenu); } return result; }
From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java
/** * Setups the Menu Bar//from ww w . j a v a 2 s . co m * @return */ private JMenuBar setupMenu() { JMenuBar menuBar = new JMenuBar(); /* -- Cluster Menu -- */ JMenu clusterMenu = new JMenu("Cluster"); clusterMenu.setMnemonic(KeyEvent.VK_C); menuBar.add(clusterMenu); // Discover Submenu JMenu clusterDiscoverMenu = new JMenu("Disover Peers"); clusterDiscoverMenu.setMnemonic(KeyEvent.VK_D); clusterMenu.add(clusterDiscoverMenu); // Discover -> Multicast JMenuItem clusterDiscoverMulticast = new JMenuItem("Multicast"); clusterDiscoverMulticast.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0)); clusterDiscoverMulticast.setEnabled(false); clusterDiscoverMulticast.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doDiscoverMulticast(); } }); clusterDiscoverMenu.add(clusterDiscoverMulticast); addUIElement("menu.cluster.discover.multicast", clusterDiscoverMulticast); // Add to components map // Discover -> WS JMenuItem clusterDiscoverWS = new JMenuItem("Colombus Web Service"); clusterDiscoverWS.setEnabled(false); clusterDiscoverWS.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0)); clusterDiscoverWS.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doDiscoverWS(); } }); clusterDiscoverMenu.add(clusterDiscoverWS); addUIElement("menu.cluster.discover.ws", clusterDiscoverWS); // Add to components map clusterMenu.addSeparator(); // Cluster-> Shutdown JMenuItem clusterShutdownItem = new JMenuItem("Shutdown", 'u'); clusterShutdownItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0)); clusterShutdownItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doShutdownCluster(); } }); clusterMenu.add(clusterShutdownItem); addUIElement("menu.cluster.shutdown", clusterShutdownItem); // Add to components map /* -- Options Menu -- */ JMenu optionsMenu = new JMenu("Options"); optionsMenu.setMnemonic(KeyEvent.VK_O); menuBar.add(optionsMenu); // Configuration JMenuItem optionsConfigItem = new JMenuItem("Configuration...", 'C'); optionsConfigItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showConfiguration(); } }); optionsMenu.add(optionsConfigItem); optionsConfigItem.setEnabled(false); // TODO Create Configuration Options /* -- Help Menu -- */ JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic(KeyEvent.VK_H); menuBar.add(helpMenu); // Help Contents JMenuItem helpContentsItem = new JMenuItem("Help Contents", 'H'); helpContentsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); helpContentsItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showHelp(); } }); helpMenu.add(helpContentsItem); helpMenu.addSeparator(); JMenuItem helpAboutItem = new JMenuItem("About", 'A'); helpAboutItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showAbout(); } }); helpMenu.add(helpAboutItem); return menuBar; }
From source file:org.rdv.viz.chart.ChartPanel.java
/** * Creates a popup menu for the panel./* www . j av a 2 s .c o m*/ * * @param properties include a menu item for the chart property editor. * @param save include a menu item for saving the chart. * @param print include a menu item for printing the chart. * @param zoom include menu items for zooming. * * @return The popup menu. */ protected JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) { JPopupMenu result = new JPopupMenu("Chart:"); boolean separator = false; if (properties) { JMenuItem propertiesItem = new JMenuItem(localizationResources.getString("Properties...")); propertiesItem.setActionCommand(PROPERTIES_COMMAND); propertiesItem.addActionListener(this); result.add(propertiesItem); separator = true; } if (save) { if (separator) { result.addSeparator(); separator = false; } JMenuItem saveItem = new JMenuItem(localizationResources.getString("Save_as...")); saveItem.setActionCommand(SAVE_COMMAND); saveItem.addActionListener(this); result.add(saveItem); separator = true; } if (print) { if (separator) { result.addSeparator(); separator = false; } JMenuItem printItem = new JMenuItem(localizationResources.getString("Print...")); printItem.setActionCommand(PRINT_COMMAND); printItem.addActionListener(this); result.add(printItem); separator = true; } if (zoom) { if (separator) { result.addSeparator(); separator = false; } JMenu zoomInMenu = new JMenu(localizationResources.getString("Zoom_In")); this.zoomInBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes")); this.zoomInBothMenuItem.setActionCommand(ZOOM_IN_BOTH_COMMAND); this.zoomInBothMenuItem.addActionListener(this); zoomInMenu.add(this.zoomInBothMenuItem); zoomInMenu.addSeparator(); this.zoomInDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis")); this.zoomInDomainMenuItem.setActionCommand(ZOOM_IN_DOMAIN_COMMAND); this.zoomInDomainMenuItem.addActionListener(this); zoomInMenu.add(this.zoomInDomainMenuItem); this.zoomInRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis")); this.zoomInRangeMenuItem.setActionCommand(ZOOM_IN_RANGE_COMMAND); this.zoomInRangeMenuItem.addActionListener(this); zoomInMenu.add(this.zoomInRangeMenuItem); result.add(zoomInMenu); JMenu zoomOutMenu = new JMenu(localizationResources.getString("Zoom_Out")); this.zoomOutBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes")); this.zoomOutBothMenuItem.setActionCommand(ZOOM_OUT_BOTH_COMMAND); this.zoomOutBothMenuItem.addActionListener(this); zoomOutMenu.add(this.zoomOutBothMenuItem); zoomOutMenu.addSeparator(); this.zoomOutDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis")); this.zoomOutDomainMenuItem.setActionCommand(ZOOM_OUT_DOMAIN_COMMAND); this.zoomOutDomainMenuItem.addActionListener(this); zoomOutMenu.add(this.zoomOutDomainMenuItem); this.zoomOutRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis")); this.zoomOutRangeMenuItem.setActionCommand(ZOOM_OUT_RANGE_COMMAND); this.zoomOutRangeMenuItem.addActionListener(this); zoomOutMenu.add(this.zoomOutRangeMenuItem); result.add(zoomOutMenu); JMenu autoRangeMenu = new JMenu(localizationResources.getString("Auto_Range")); this.zoomResetBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes")); this.zoomResetBothMenuItem.setActionCommand(ZOOM_RESET_BOTH_COMMAND); this.zoomResetBothMenuItem.addActionListener(this); autoRangeMenu.add(this.zoomResetBothMenuItem); autoRangeMenu.addSeparator(); this.zoomResetDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis")); this.zoomResetDomainMenuItem.setActionCommand(ZOOM_RESET_DOMAIN_COMMAND); this.zoomResetDomainMenuItem.addActionListener(this); autoRangeMenu.add(this.zoomResetDomainMenuItem); this.zoomResetRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis")); this.zoomResetRangeMenuItem.setActionCommand(ZOOM_RESET_RANGE_COMMAND); this.zoomResetRangeMenuItem.addActionListener(this); autoRangeMenu.add(this.zoomResetRangeMenuItem); result.addSeparator(); result.add(autoRangeMenu); } return result; }
From source file:org.fhaes.jsea.JSEAFrame.java
/** * Setup menu bar/*from w ww . j a v a2s . com*/ */ private void setupMenu() { JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); { JMenu mnFile = new JMenu("File"); menuBar.add(mnFile); { JMenuItem mntmClose = new JMenuItem(actionFileExit); { JMenuItem mntmNew = new JMenuItem(actionReset); mnFile.add(mntmNew); } { mnSave = new JMenu("Save"); mnSave.setIcon(Builder.getImageIcon("save.png")); mnFile.add(mnSave); { JMenuItem mntmChart = new JMenuItem(actionSaveChart); mnSave.add(mntmChart); } { JMenuItem mntmReport = new JMenuItem(actionSaveReport); mnSave.add(mntmReport); } { JMenuItem mntmData = new JMenuItem(actionSaveData); mnSave.add(mntmData); } mnSave.addSeparator(); { JMenuItem mntmAll = new JMenuItem(actionSaveAll); mnSave.add(mntmAll); } } mnFile.addSeparator(); mnFile.add(mntmClose); } } { JMenu mnEdit = new JMenu("Edit"); menuBar.add(mnEdit); { JMenuItem mntmCopy = new JMenuItem(actionCopy); mnEdit.add(mntmCopy); JMenuItem mntmChartProperties = new JMenuItem(actionChartProperties); mnEdit.add(mntmChartProperties); mnEdit.addSeparator(); JMenuItem mntmRun = new JMenuItem(actionRun); mnEdit.add(mntmRun); } } { JMenu mnTools = new JMenu("Tools"); menuBar.add(mnTools); { JMenuItem mntmLagMap = new JMenuItem(actionLagMap); mnTools.add(mntmLagMap); } } { JMenu mnHelp = new JMenu("Help"); menuBar.add(mnHelp); { JMenuItem mntmHelp = new JMenuItem(MainWindow.actionHelp); mnHelp.add(mntmHelp); } mnHelp.addSeparator(); { JMenuItem mntmAbout = new JMenuItem(MainWindow.actionAbout); mnHelp.add(mntmAbout); } } }
From source file:com.lfv.lanzius.server.LanziusServer.java
public void init() { log.info(Config.VERSION + "\n"); docVersion = 0;/* w ww .jav a 2 s . co m*/ frame = new JFrame(Config.TITLE + " - Server Control Panel"); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { actionPerformed(new ActionEvent(itemExit, 0, null)); } }); // Create graphical terminal view panel = new WorkspacePanel(this); frame.getContentPane().add(panel); // Create a menu bar JMenuBar menuBar = new JMenuBar(); // FILE JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); // Load configuration itemLoadConfig = new JMenuItem("Load configuration..."); itemLoadConfig.addActionListener(this); fileMenu.add(itemLoadConfig); // Load terminal setup itemLoadExercise = new JMenuItem("Load exercise..."); itemLoadExercise.addActionListener(this); fileMenu.add(itemLoadExercise); fileMenu.addSeparator(); // Exit itemExit = new JMenuItem("Exit"); itemExit.addActionListener(this); fileMenu.add(itemExit); menuBar.add(fileMenu); // SERVER JMenu serverMenu = new JMenu("Server"); serverMenu.setMnemonic(KeyEvent.VK_S); // Start itemServerStart = new JMenuItem("Start"); itemServerStart.addActionListener(this); serverMenu.add(itemServerStart); // Stop itemServerStop = new JMenuItem("Stop"); itemServerStop.addActionListener(this); serverMenu.add(itemServerStop); // Restart itemServerRestart = new JMenuItem("Restart"); itemServerRestart.addActionListener(this); itemServerRestart.setEnabled(false); serverMenu.add(itemServerRestart); // Monitor network connection itemServerMonitor = new JCheckBoxMenuItem("Monitor network"); itemServerMonitor.addActionListener(this); itemServerMonitor.setState(false); serverMenu.add(itemServerMonitor); menuBar.add(serverMenu); // TERMINAL JMenu terminalMenu = new JMenu("Terminal"); terminalMenu.setMnemonic(KeyEvent.VK_T); itemTerminalLink = new JMenuItem("Link..."); itemTerminalLink.addActionListener(this); terminalMenu.add(itemTerminalLink); itemTerminalUnlink = new JMenuItem("Unlink..."); itemTerminalUnlink.addActionListener(this); terminalMenu.add(itemTerminalUnlink); itemTerminalUnlinkAll = new JMenuItem("Unlink All"); itemTerminalUnlinkAll.addActionListener(this); terminalMenu.add(itemTerminalUnlinkAll); itemTerminalSwap = new JMenuItem("Swap..."); itemTerminalSwap.addActionListener(this); terminalMenu.add(itemTerminalSwap); menuBar.add(terminalMenu); // GROUP JMenu groupMenu = new JMenu("Group"); groupMenu.setMnemonic(KeyEvent.VK_G); itemGroupStart = new JMenuItem("Start..."); itemGroupStart.addActionListener(this); groupMenu.add(itemGroupStart); itemGroupPause = new JMenuItem("Pause..."); itemGroupPause.addActionListener(this); groupMenu.add(itemGroupPause); itemGroupStop = new JMenuItem("Stop..."); itemGroupStop.addActionListener(this); groupMenu.add(itemGroupStop); menuBar.add(groupMenu); frame.setJMenuBar(menuBar); GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle maximumWindowBounds = graphicsEnvironment.getMaximumWindowBounds(); if (Config.SERVER_SIZE_FULLSCREEN) { maximumWindowBounds.setLocation(0, 0); maximumWindowBounds.setSize(Toolkit.getDefaultToolkit().getScreenSize()); frame.setResizable(false); frame.setUndecorated(true); } else if (Config.SERVER_SIZE_100P_WINDOW) { // Fixes a bug in linux using gnome. With the line below the upper and // lower bars are respected maximumWindowBounds.height -= 1; } else if (Config.SERVER_SIZE_75P_WINDOW) { maximumWindowBounds.width *= 0.75; maximumWindowBounds.height *= 0.75; } else if (Config.SERVER_SIZE_50P_WINDOW) { maximumWindowBounds.width /= 2; maximumWindowBounds.height /= 2; } frame.setBounds(maximumWindowBounds); frame.setVisible(true); log.info("Starting control panel"); // Autostart for debugging if (Config.SERVER_AUTOLOAD_CONFIGURATION != null) actionPerformed(new ActionEvent(itemLoadConfig, 0, null)); if (Config.SERVER_AUTOSTART_SERVER) actionPerformed(new ActionEvent(itemServerStart, 0, null)); if (Config.SERVER_AUTOLOAD_EXERCISE != null) actionPerformed(new ActionEvent(itemLoadExercise, 0, null)); if (Config.SERVER_AUTOSTART_GROUP > 0) actionPerformed(new ActionEvent(itemGroupStart, 0, null)); try { // Read the property files serverProperties = new Properties(); serverProperties.loadFromXML(new FileInputStream("data/properties/serverproperties.xml")); int rcPort = Integer.parseInt(serverProperties.getProperty("RemoteControlPort", "0")); if (rcPort > 0) { groupRemoteControlListener(rcPort); } isaPeriod = Integer.parseInt(serverProperties.getProperty("ISAPeriod", "60")); isaNumChoices = Integer.parseInt(serverProperties.getProperty("ISANumChoices", "6")); for (int i = 0; i < 9; i++) { String tag = "ISAKeyText" + Integer.toString(i); String def_val = Integer.toString(i + 1); isakeytext[i] = serverProperties.getProperty(tag, def_val); } isaExtendedMode = serverProperties.getProperty("ISAExtendedMode", "false").equalsIgnoreCase("true"); } catch (Exception e) { log.error("Unable to start remote control listener"); log.error(e.getMessage()); } isaClients = new HashSet<Integer>(); }