List of usage examples for javax.swing JMenu addSeparator
public void addSeparator()
From source file:org.fhaes.fhsamplesize.view.FHSampleSize.java
/** * Set up the Menu bar using actions wherever possible. *//* ww w. ja v a 2s . c o m*/ private void initMenu() { JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnFile = new JMenu("File"); menuBar.add(mnFile); JMenuItem mntmOpen = new JMenuItem(this.actionBrowse); mntmOpen.setText("Open..."); mnFile.add(mntmOpen); JMenu mnSave = new JMenu("Save..."); mnFile.add(mnSave); JMenuItem mntmSaveTable = new JMenuItem(this.actionSaveTable); mnSave.add(mntmSaveTable); JMenuItem mntmSaveChartPDF = new JMenuItem(this.actionExportPDF); mnSave.add(mntmSaveChartPDF); JMenuItem mntmSaveChartPNG = new JMenuItem(this.actionExportPNG); mnSave.add(mntmSaveChartPNG); mnFile.addSeparator(); JMenuItem mntmExit = new JMenuItem(this.actionClose); mnFile.add(mntmExit); }
From source file:ffx.ui.MainMenu.java
/** * <p>//w w w .j a v a2s. c om * Constructor for MainMenu.</p> * * @param f a {@link ffx.ui.MainPanel} object. */ public MainMenu(MainPanel f) { // Create the Tool Bar toolBar = new JToolBar("Toolbar", JToolBar.HORIZONTAL); toolBar.setBorderPainted(true); toolBar.setRollover(true); JButton temp = new JButton(); insets = temp.getInsets(); insets.set(2, 2, 2, 2); mainPanel = f; graphics = mainPanel.getGraphics3D(); locale = mainPanel.getFFXLocale(); loader = getClass().getClassLoader(); blankIcon = new ImageIcon(loader.getResource(icons + "blank.gif")); String value = System.getProperty("structures", "false").trim(); try { includeStructureMenu = Boolean.parseBoolean(value); } catch (Exception e) { includeStructureMenu = false; } /** * Main Menubar */ JMenu fileMenu = addMenu("File", 'F'); JMenu selectionMenu = addMenu("Selection", 'E'); JMenu structureMenu = null; if (includeStructureMenu) { structureMenu = addMenu("Structure", 'S'); } JMenu displayMenu = addMenu("Display", 'D'); JMenu colorMenu = addMenu("Color", 'C'); JMenu optionsMenu = addMenu("Options", 'O'); JMenu pickingMenu = addMenu("Picking", 'P'); JMenu trajectoryMenu = addMenu("Trajectory", 'T'); JMenu exportMenu = addMenu("Export", 'X'); JMenu windowMenu = addMenu("Window", 'W'); JMenu helpMenu = addMenu("Help", 'H'); /** * File Menu - Events Handled by the MainPanel Class. */ addMenuItem(fileMenu, icons + "folder_page", "Open", 'O', KeyEvent.VK_O, mainPanel); addMenuItem(fileMenu, icons + "disk", "SaveAs", 'S', KeyEvent.VK_S, mainPanel); addMenuItem(fileMenu, icons + "cancel", "Close", 'C', -1, mainPanel); addMenuItem(fileMenu, "BLANK", "CloseAll", 'A', -1, mainPanel); fileMenu.addSeparator(); addMenuItem(fileMenu, icons + "drive_web", "DownloadFromPDB", 'D', KeyEvent.VK_D, mainPanel); fileMenu.addSeparator(); addMenuItem(fileMenu, "BLANK", "ChooseKeyFile", 'R', -1, mainPanel); addMenuItem(fileMenu, "BLANK", "ChooseLogFile", 'I', -1, mainPanel); addMenuItem(fileMenu, "BLANK", "LoadRestartData", 'R', -1, mainPanel); if (!SystemUtils.IS_OS_MAC_OSX) { fileMenu.addSeparator(); addMenuItem(fileMenu, "BLANK", "Exit", 'E', KeyEvent.VK_Q, mainPanel); } toolBar.addSeparator(); /** * Selection Menu - Events Handled by the MainPanel and GraphicsCanvas. */ addMenuItem(selectionMenu, icons + "add", "SelectAll", 'A', KeyEvent.VK_A, mainPanel); addMenuItem(selectionMenu, "BLANK", "RestrictToSelections", 'R', -1, graphics); addMenuItem(selectionMenu, icons + "arrow_merge", "MergeSelections", 'M', -1, mainPanel); selectionMenu.addSeparator(); highlightCBMI = addCBMenuItem(selectionMenu, icons + "asterisk_yellow", "HighlightSelections", 'H', KeyEvent.VK_H, mainPanel); addMenuItem(selectionMenu, "BLANK", "SetSelectionColor", 'S', -1, graphics); selectionMenu.addSeparator(); labelAtomsMI = addCBMenuItem(selectionMenu, "BLANK", "LabelSelectedAtoms", 'O', -1, graphics); labelResiduesMI = addCBMenuItem(selectionMenu, "BLANK", "LabelSelectedResidues", 'R', -1, graphics); addMenuItem(selectionMenu, "BLANK", "SetLabelFontSize", 'Z', -1, graphics); addMenuItem(selectionMenu, "BLANK", "SetLabelFontColor", 'C', -1, graphics); highlightCBMI.setSelected(false); labelAtomsMI.setSelected(false); labelResiduesMI.setSelected(false); toolBar.addSeparator(); /** * Structure Menu - Events Handled by the MainPanel. */ if (includeStructureMenu) { // Locate a jar file that has PDB Structures. String file = "ffx/xray/structures/1N7S.pdb"; addMenuItem(structureMenu, "BLANK", file, '.', -1, mainPanel); } /** * Display Menu - Events handled by the GraphicsCanvas. */ addMenuItem(displayMenu, "BLANK", "Wireframe", 'W', -1, graphics); addMenuItem(displayMenu, "BLANK", "Tube", 'T', -1, graphics); addMenuItem(displayMenu, "BLANK", "Spacefill", 'S', -1, graphics); addMenuItem(displayMenu, "BLANK", "BallAndStick", 'B', -1, graphics); addMenuItem(displayMenu, "BLANK", "Invisible", 'I', -1, graphics); addMenuItem(displayMenu, "BLANK", "RMIN", 'R', -1, graphics); displayMenu.addSeparator(); addMenuItem(displayMenu, "BLANK", "ShowHydrogens", 'H', -1, graphics); addMenuItem(displayMenu, "BLANK", "HideHydrogens", 'Y', -1, graphics); displayMenu.addSeparator(); addMenuItem(displayMenu, "BLANK", "Fill", 'F', -1, graphics); addMenuItem(displayMenu, "BLANK", "Points", 'P', -1, graphics); addMenuItem(displayMenu, "BLANK", "Lines", 'I', -1, graphics); displayMenu.addSeparator(); addMenuItem(displayMenu, "BLANK", "Preferences", 'P', -1, graphics); /** * Color Menu - Events handled by the GraphicsCanvas. */ addMenuItem(colorMenu, "BLANK", "Monochrome", 'M', -1, graphics); addMenuItem(colorMenu, "BLANK", "CPK", 'C', -1, graphics); addMenuItem(colorMenu, "BLANK", "Residue", 'R', -1, graphics); addMenuItem(colorMenu, "BLANK", "Structure", 'S', -1, graphics); addMenuItem(colorMenu, "BLANK", "Polymer", 'M', -1, graphics); addMenuItem(colorMenu, "BLANK", "PartialCharge", 'P', -1, graphics); addMenuItem(colorMenu, "BLANK", "UserColor", 'U', -1, graphics); colorMenu.addSeparator(); addMenuItem(colorMenu, "BLANK", "ApplyUserColor", 'A', -1, graphics); addMenuItem(colorMenu, "BLANK", "SetUserColor", 'C', -1, graphics); /** * Options Menu - Events handled by the GraphicsCanvas. */ dragModeButtonGroup = new ButtonGroup(); activeRBMI = addBGMI(dragModeButtonGroup, optionsMenu, "BLANK", "ActiveSystem", 'A', KeyEvent.VK_A, graphics); mouseRBMI = addBGMI(dragModeButtonGroup, optionsMenu, "BLANK", "SystemBelowMouse", 'S', KeyEvent.VK_M, graphics); activeRBMI.setSelected(true); optionsMenu.addSeparator(); JMenu leftMouseMenu = addSubMenu(optionsMenu, "LeftMouseButton", 'M'); leftMouseButtonGroup = new ButtonGroup(); rotateRBMI = addBGMI(leftMouseButtonGroup, leftMouseMenu, "BLANK", "Rotate", 'R', KeyEvent.VK_R, graphics); addBGMI(leftMouseButtonGroup, leftMouseMenu, "BLANK", "Translate", 'T', KeyEvent.VK_T, graphics); addBGMI(leftMouseButtonGroup, leftMouseMenu, "BLANK", "Zoom", 'Z', KeyEvent.VK_Z, graphics); rotateRBMI.setSelected(true); optionsMenu.addSeparator(); addMenuItem(optionsMenu, "BLANK", "RotateAboutCenter", 'C', KeyEvent.VK_C, graphics); addMenuItem(optionsMenu, "BLANK", "RotateAboutPick", 'P', KeyEvent.VK_P, graphics); addMenuItem(optionsMenu, "BLANK", "ResetRotation", 'R', -1, graphics); addMenuItem(optionsMenu, "BLANK", "ResetTranslation", 'T', -1, graphics); addMenuItem(optionsMenu, icons + "arrow_refresh", "ResetRotationAndTranslation", 'E', -1, graphics); optionsMenu.addSeparator(); addMenuItem(optionsMenu, icons + "magnifier_zoom_in", "ZoomIn", 'I', -1, graphics); addMenuItem(optionsMenu, icons + "magnifier_zoom_out", "ZoomOut", 'O', -1, graphics); addMenuItem(optionsMenu, "BLANK", "ResetGlobalZoom", 'Z', -1, graphics); addMenuItem(optionsMenu, "BLANK", "ResetGlobalRotation", 'N', -1, graphics); addMenuItem(optionsMenu, "BLANK", "ResetGlobalTranslation", 'O', -1, graphics); addMenuItem(optionsMenu, icons + "house", "ResetGlobalView", 'V', -1, graphics); optionsMenu.addSeparator(); addMenuItem(optionsMenu, "BLANK", "SetBackgroundColor", 'B', -1, graphics); toolBar.addSeparator(); /** * Picking Menu - Events handled by the GraphicsCanvas. */ levelBG = new ButtonGroup(); pickingCBMI = addCBMenuItem(pickingMenu, icons + "wand", "GraphicsPicking", 'G', KeyEvent.VK_0, graphics); pickingCBMI.setSelected(false); pickingMenu.addSeparator(); atomRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickAtom", 'A', KeyEvent.VK_1, graphics); bondRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickBond", 'B', KeyEvent.VK_2, graphics); angleRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickAngle", 'N', KeyEvent.VK_3, graphics); dihedralRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickDihedral", 'D', KeyEvent.VK_4, graphics); residueRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickResidue", 'R', KeyEvent.VK_5, graphics); polymerRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickPolymer", 'P', KeyEvent.VK_6, graphics); moleculeRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickMolecule", 'M', KeyEvent.VK_7, graphics); systemRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "PickSystem", 'S', KeyEvent.VK_8, graphics); pickingMenu.addSeparator(); measureDistanceRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "MeasureDistance", 'I', -1, graphics); measureAngleRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "MeasureAngle", 'L', -1, graphics); measureDihedralRBMI = addBGMI(levelBG, pickingMenu, "BLANK", "MeasureDihedral", 'H', -1, graphics); atomRBMI.setSelected(true); pickingMenu.addSeparator(); addMenuItem(pickingMenu, "BLANK", "SetGraphicsPickingColor", 'S', -1, graphics); toolBar.addSeparator(); /** * Trajectory Menu - Events handled by the MainPanel. */ oscillateCBMI = addCBMenuItem(trajectoryMenu, icons + "control_repeat_blue", "Oscillate", 'O', -1, mainPanel); oscillateCBMI.setSelected(false); addMenuItem(trajectoryMenu, "BLANK", "Frame", 'A', -1, mainPanel); addMenuItem(trajectoryMenu, "BLANK", "Speed", 'E', -1, mainPanel); addMenuItem(trajectoryMenu, "BLANK", "Skip", 'K', -1, mainPanel); trajectoryMenu.addSeparator(); addMenuItem(trajectoryMenu, icons + "control_play_blue", "Play", 'P', -1, mainPanel); addMenuItem(trajectoryMenu, icons + "control_stop_blue", "Stop", 'S', -1, mainPanel); addMenuItem(trajectoryMenu, icons + "control_fastforward_blue", "StepForward", 'F', -1, mainPanel); addMenuItem(trajectoryMenu, icons + "control_rewind_blue", "StepBack", 'B', -1, mainPanel); addMenuItem(trajectoryMenu, icons + "control_start_blue", "Reset", 'R', -1, mainPanel); toolBar.addSeparator(); /** * Export Menu - Events handled by the GraphicsCanvas. */ addMenuItem(exportMenu, icons + "camera", "CaptureGraphics", 'C', KeyEvent.VK_G, graphics); exportMenu.addSeparator(); captureFormatButtonGroup = new ButtonGroup(); addBGMI(captureFormatButtonGroup, exportMenu, "BLANK", "PNG", 'P', -1, graphics).setSelected(true); addBGMI(captureFormatButtonGroup, exportMenu, "BLANK", "JPEG", 'J', -1, graphics); addBGMI(captureFormatButtonGroup, exportMenu, "BLANK", "BMP", 'B', -1, graphics); addBGMI(captureFormatButtonGroup, exportMenu, "BLANK", "WBMP", 'W', -1, graphics); addBGMI(captureFormatButtonGroup, exportMenu, "BLANK", "GIF", 'G', -1, graphics); toolBar.addSeparator(); /** * Window Menu - Events handled by the GraphicsCanvas. */ addMenuItem(windowMenu, icons + "application_home", "ResetPanes", 'R', -1, mainPanel); addMenuItem(windowMenu, icons + "application_osx_terminal", "ResetConsole", 'L', -1, mainPanel); windowMenu.addSeparator(); addMenuItem(windowMenu, icons + "application_side_contract", "ExpandGraphicsWindow", 'E', -1, mainPanel); addMenuItem(windowMenu, icons + "application_side_expand", "ShrinkGraphicsWindow", 'L', -1, mainPanel); windowMenu.addSeparator(); systemsCBMI = addCBMenuItem(windowMenu, "BLANK", "ShowTree", 'T', -1, mainPanel); toolBarCBMI = addCBMenuItem(windowMenu, "BLANK", "ShowToolBar", 'B', -1, mainPanel); globalAxisCBMI = addCBMenuItem(windowMenu, "BLANK", "ShowGlobalAxes", 'C', -1, mainPanel); globalAxisCBMI.setSelected(true); toolBar.addSeparator(); /** * Help Menu - Events handled by the MainPanel. */ Action a = addMenuItem(helpMenu, icons + "help", "HelpContents", 'H', KeyEvent.VK_HELP, mainPanel); /** * Fix the ACCELERATOR_KEY for the Help menu item; no modifiers will be * used. */ a.putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_HELP, 0)); addMenuItem(helpMenu, "BLANK", "About", 'A', -1, mainPanel); }
From source file:edu.ku.brc.specify.tools.schemalocale.SchemaLocalizerFrame.java
/** * //from w ww . j ava 2 s . c om */ protected void buildUI() { SchemaLocalizerXMLHelper slxh = new SchemaLocalizerXMLHelper(schemaType, tableMgr); localizableIO = slxh; localizableIO.load(false); //stripToSingleLocale("pt", slxh); LocalizableStrFactory localizableStrFactory = new LocalizableStrFactory() { public LocalizableStrIFace create() { SpLocaleItemStr str = new SpLocaleItemStr(); str.initialize(); return str; } public LocalizableStrIFace create(String text, Locale locale) { return new SpLocaleItemStr(text, locale); // no initialize needed for this constructor } }; LocalizerBasePanel.setLocalizableStrFactory(localizableStrFactory); SchemaLocalizerXMLHelper.setLocalizableStrFactory(localizableStrFactory); schemaLocPanel = new SchemaLocalizerPanel(null, dataObjFieldFormatMgrCache, uiFieldFormatterMgrCache, webLinkMgrCache, schemaType); schemaLocPanel.setLocalizableIO(localizableIO); schemaLocPanel.setStatusBar(statusBar); boolean useDisciplines = AppPreferences.getLocalPrefs().getBoolean("SCHEMA_DISP", false); schemaLocPanel.setUseDisciplines(useDisciplines); // rods - for now //schemaLocPanel.setIncludeHiddenUI(true); schemaLocPanel.buildUI(); schemaLocPanel.setHasChanged(localizableIO.didModelChangeDuringLoad()); statusBar.setSectionText(1, schemaType == SpLocaleContainer.CORE_SCHEMA ? getResourceString("SchemaLocalizerFrame.FULL_SCHEMA") //$NON-NLS-1$ : getResourceString("SchemaLocalizerFrame.WB_SCHEMA")); //$NON-NLS-1$ UIRegistry.setStatusBar(statusBar); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); String title = "File"; //$NON-NLS-1$ String mneu = "F"; //$NON-NLS-1$ JMenu fileMenu = UIHelper.createLocalizedMenu(menuBar, title, mneu); title = "Save"; //$NON-NLS-1$ mneu = "S"; //$NON-NLS-1$ JMenuItem saveMenuItem = UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", false, //$NON-NLS-1$ new ActionListener() { public void actionPerformed(ActionEvent e) { write(); } }); saveMenuItem.setEnabled(false); title = "Export"; //$NON-NLS-1$ mneu = "E"; //$NON-NLS-1$ UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, new ActionListener() //$NON-NLS-1$ { public void actionPerformed(ActionEvent e) { export(); } }); title = "SchemaLocalizerFrame.ExportLOCALE"; //$NON-NLS-1$ mneu = "SchemaLocalizerFrame.ExportLOCALEMnu"; //$NON-NLS-1$ UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, new ActionListener() //$NON-NLS-1$ { public void actionPerformed(ActionEvent e) { exportSingleLocale(); } }); title = "Exit"; //$NON-NLS-1$ mneu = "x"; //$NON-NLS-1$ if (!UIHelper.isMacOS()) { fileMenu.addSeparator(); UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, new ActionListener() //$NON-NLS-1$ { public void actionPerformed(ActionEvent e) { shutdown(); } }); } /* JMenu toolMenu = UIHelper.createMenu(menuBar, "Tools", "T"); UIHelper.createMenuItem(toolMenu, "Create Resource Files", "C", "", true, new ActionListener() { public void actionPerformed(ActionEvent e) { createResourceFiles(); } }); */ menuBar.add(SchemaI18NService.getInstance().createLocaleMenu(this, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("locale")) //$NON-NLS-1$ { schemaLocPanel.localeChanged((Locale) evt.getNewValue()); statusBar.setSectionText(0, SchemaI18NService.getCurrentLocale().getDisplayName()); } } })); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setSize(800, 600); JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(schemaLocPanel, BorderLayout.CENTER); mainPanel.add(statusBar, BorderLayout.SOUTH); mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); setContentPane(mainPanel); statusBar.setSectionText(0, SchemaI18NService.getCurrentLocale().getDisplayName()); schemaLocPanel.setSaveMenuItem(saveMenuItem); schemaLocPanel.getContainerList().setEnabled(true); AppPreferences localPrefs = AppPreferences.getLocalPrefs(); localPrefs.setDirPath(UIRegistry.getAppDataDir()); ImageIcon helpIcon = IconManager.getIcon("AppIcon", IconSize.Std16); //$NON-NLS-1$ HelpMgr.initializeHelp("SpecifyHelp", helpIcon.getImage()); //$NON-NLS-1$ AppPrefsCache.setUseLocalOnly(true); SpecifyAppPrefs.loadColorAndFormatPrefs(); if (localizableIO.didModelChangeDuringLoad()) { saveMenuItem.setEnabled(true); SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame(getResourceString("SchemaLocalizerFrame.CHG_TO_SCHEMA")); //$NON-NLS-1$ frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); JTextPane tp = new JTextPane(); JScrollPane js = new JScrollPane(); js.getViewport().add(tp); tp.setContentType("text/html"); tp.setText(((SchemaLocalizerXMLHelper) localizableIO).getChangesBuffer()); frame.setContentPane(js); frame.pack(); frame.setSize(400, 500); frame.setVisible(true); } }); } }
From source file:edu.ku.brc.specify.utilapps.RegisterApp.java
/** * /*from w w w . j av a2 s . c om*/ */ protected void doStart() { frame = new JFrame(); JMenuBar mb = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenu rptMenu = new JMenu("Reports"); //JMenu chrtMenu = new JMenu("Charts"); frame.setTitle(title); JMenuItem doISARegReportMI = new JMenuItem("ISA Reg Report"); rptMenu.add(doISARegReportMI); JMenuItem doStatsMI = new JMenuItem("Registration"); rptMenu.add(doStatsMI); //JMenuItem doMiscMI = new JMenuItem("Misc"); //chrtMenu.add(doMiscMI); //menu.addSeparator(); JMenuItem doSetVersionMI = new JMenuItem("Set Version"); fileMenu.add(doSetVersionMI); if (!UIHelper.isMacOS()) { fileMenu.addSeparator(); JMenuItem doExitMI = new JMenuItem("Exit"); fileMenu.add(doExitMI); doExitMI.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doExit(true); } }); } mb.add(fileMenu); mb.add(rptMenu); //mb.add(chrtMenu); frame.setJMenuBar(mb); frame.setContentPane(this); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(0, 0, 600, 768); UIHelper.centerAndShow(frame); doISARegReportMI.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { createRegReport(); } }); doStatsMI.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { createStatsReport(); } }); doSetVersionMI.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doSetVersion(); } }); }
From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java
/** * Creates a popup menu for the panel.//from w w w .j av a2s . com * * @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_ACTION_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_ACTION_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_ACTION_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")); zoomInBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes")); zoomInBothMenuItem.setActionCommand(ZOOM_IN_BOTH_ACTION_COMMAND); zoomInBothMenuItem.addActionListener(this); zoomInMenu.add(zoomInBothMenuItem); zoomInMenu.addSeparator(); zoomInHorizontalMenuItem = new JMenuItem(localizationResources.getString("Horizontal_Axis")); zoomInHorizontalMenuItem.setActionCommand(ZOOM_IN_HORIZONTAL_ACTION_COMMAND); zoomInHorizontalMenuItem.addActionListener(this); zoomInMenu.add(zoomInHorizontalMenuItem); zoomInVerticalMenuItem = new JMenuItem(localizationResources.getString("Vertical_Axis")); zoomInVerticalMenuItem.setActionCommand(ZOOM_IN_VERTICAL_ACTION_COMMAND); zoomInVerticalMenuItem.addActionListener(this); zoomInMenu.add(zoomInVerticalMenuItem); result.add(zoomInMenu); JMenu zoomOutMenu = new JMenu(localizationResources.getString("Zoom_Out")); zoomOutBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes")); zoomOutBothMenuItem.setActionCommand(ZOOM_OUT_BOTH_ACTION_COMMAND); zoomOutBothMenuItem.addActionListener(this); zoomOutMenu.add(zoomOutBothMenuItem); zoomOutMenu.addSeparator(); zoomOutHorizontalMenuItem = new JMenuItem(localizationResources.getString("Horizontal_Axis")); zoomOutHorizontalMenuItem.setActionCommand(ZOOM_OUT_HORIZONTAL_ACTION_COMMAND); zoomOutHorizontalMenuItem.addActionListener(this); zoomOutMenu.add(zoomOutHorizontalMenuItem); zoomOutVerticalMenuItem = new JMenuItem(localizationResources.getString("Vertical_Axis")); zoomOutVerticalMenuItem.setActionCommand(ZOOM_OUT_VERTICAL_ACTION_COMMAND); zoomOutVerticalMenuItem.addActionListener(this); zoomOutMenu.add(zoomOutVerticalMenuItem); result.add(zoomOutMenu); JMenu autoRangeMenu = new JMenu(localizationResources.getString("Auto_Range")); autoRangeBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes")); autoRangeBothMenuItem.setActionCommand(AUTO_RANGE_BOTH_ACTION_COMMAND); autoRangeBothMenuItem.addActionListener(this); autoRangeMenu.add(autoRangeBothMenuItem); autoRangeMenu.addSeparator(); autoRangeHorizontalMenuItem = new JMenuItem(localizationResources.getString("Horizontal_Axis")); autoRangeHorizontalMenuItem.setActionCommand(AUTO_RANGE_HORIZONTAL_ACTION_COMMAND); autoRangeHorizontalMenuItem.addActionListener(this); autoRangeMenu.add(autoRangeHorizontalMenuItem); autoRangeVerticalMenuItem = new JMenuItem(localizationResources.getString("Vertical_Axis")); autoRangeVerticalMenuItem.setActionCommand(AUTO_RANGE_VERTICAL_ACTION_COMMAND); autoRangeVerticalMenuItem.addActionListener(this); autoRangeMenu.add(autoRangeVerticalMenuItem); result.addSeparator(); result.add(autoRangeMenu); } return result; }
From source file:edu.brown.gui.CatalogViewer.java
/** * // w w w. j a va 2s .co m */ protected void viewerInit() { // ---------------------------------------------- // MENU // ---------------------------------------------- JMenu menu; JMenuItem menuItem; // // File Menu // menu = new JMenu("File"); menu.getPopupMenu().setLightWeightPopupEnabled(false); menu.setMnemonic(KeyEvent.VK_F); menu.getAccessibleContext().setAccessibleDescription("File Menu"); menuBar.add(menu); menuItem = new JMenuItem("Open Catalog From File"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Open Catalog From File"); menuItem.addActionListener(this.menuHandler); menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.CATALOG_OPEN_FILE); menu.add(menuItem); menuItem = new JMenuItem("Open Catalog From Jar"); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Open Catalog From Project Jar"); menuItem.addActionListener(this.menuHandler); menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.CATALOG_OPEN_JAR); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem("Quit", KeyEvent.VK_Q); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Quit Program"); menuItem.addActionListener(this.menuHandler); menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.QUIT); menu.add(menuItem); // ---------------------------------------------- // CATALOG TREE PANEL // ---------------------------------------------- this.catalogTree = new JTree(); this.catalogTree.setEditable(false); this.catalogTree.setCellRenderer(new CatalogViewer.CatalogTreeRenderer()); this.catalogTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); this.catalogTree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) CatalogViewer.this.catalogTree .getLastSelectedPathComponent(); if (node == null) return; Object user_obj = node.getUserObject(); String new_text = ""; // <html>"; boolean text_mode = true; if (user_obj instanceof WrapperNode) { CatalogType catalog_obj = ((WrapperNode) user_obj).getCatalogType(); new_text += CatalogViewer.this.getAttributesText(catalog_obj); } else if (user_obj instanceof AttributesNode) { AttributesNode wrapper = (AttributesNode) user_obj; new_text += wrapper.getAttributes(); } else if (user_obj instanceof PlanTreeCatalogNode) { final PlanTreeCatalogNode wrapper = (PlanTreeCatalogNode) user_obj; text_mode = false; CatalogViewer.this.mainPanel.remove(0); CatalogViewer.this.mainPanel.add(wrapper.getPanel(), BorderLayout.CENTER); CatalogViewer.this.mainPanel.validate(); CatalogViewer.this.mainPanel.repaint(); if (SwingUtilities.isEventDispatchThread() == false) { SwingUtilities.invokeLater(new Runnable() { public void run() { wrapper.centerOnRoot(); } }); } else { wrapper.centerOnRoot(); } } else { new_text += CatalogViewer.this.getSummaryText(); } // Text Mode if (text_mode) { if (CatalogViewer.this.text_mode == false) { CatalogViewer.this.mainPanel.remove(0); CatalogViewer.this.mainPanel.add(CatalogViewer.this.textInfoPanel); } CatalogViewer.this.textInfoTextArea.setText(new_text); // Scroll to top CatalogViewer.this.textInfoTextArea.grabFocus(); } CatalogViewer.this.text_mode = text_mode; } }); this.generateCatalogTree(this.catalog, this.catalog_file_path.getName()); // // Text Information Panel // this.textInfoPanel = new JPanel(); this.textInfoPanel.setLayout(new BorderLayout()); this.textInfoTextArea = new JTextArea(); this.textInfoTextArea.setEditable(false); this.textInfoTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); this.textInfoTextArea.setText(this.getSummaryText()); this.textInfoTextArea.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { // TODO Auto-generated method stub } @Override public void focusGained(FocusEvent e) { CatalogViewer.this.scrollTextInfoToTop(); } }); this.textInfoScroller = new JScrollPane(this.textInfoTextArea); this.textInfoPanel.add(this.textInfoScroller, BorderLayout.CENTER); this.mainPanel = new JPanel(new BorderLayout()); this.mainPanel.add(textInfoPanel, BorderLayout.CENTER); // // Search Toolbar // JPanel searchPanel = new JPanel(); searchPanel.setLayout(new BorderLayout()); JPanel innerSearchPanel = new JPanel(); innerSearchPanel.setLayout(new BoxLayout(innerSearchPanel, BoxLayout.X_AXIS)); innerSearchPanel.add(new JLabel("Search: ")); this.searchField = new JTextField(30); innerSearchPanel.add(this.searchField); searchPanel.add(innerSearchPanel, BorderLayout.EAST); this.searchField.addKeyListener(new KeyListener() { private String last = null; @Override public void keyReleased(KeyEvent e) { String value = CatalogViewer.this.searchField.getText().toLowerCase().trim(); if (!value.isEmpty() && (this.last == null || !this.last.equals(value))) { CatalogViewer.this.search(value); } this.last = value; } @Override public void keyTyped(KeyEvent e) { // Do nothing... } @Override public void keyPressed(KeyEvent e) { // Do nothing... } }); // Putting it all together JScrollPane scrollPane = new JScrollPane(this.catalogTree); JPanel topPanel = new JPanel(); topPanel.setLayout(new BorderLayout()); topPanel.add(searchPanel, BorderLayout.NORTH); topPanel.add(scrollPane, BorderLayout.CENTER); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, topPanel, this.mainPanel); splitPane.setDividerLocation(400); this.add(splitPane, BorderLayout.CENTER); }
From source file:com.adobe.aem.demo.gui.AemDemo.java
@SuppressWarnings({ "rawtypes", "unchecked" }) private void initialize() { // Initialize properties setDefaultProperties(AemDemoUtils//from w ww. j a v a2s.co m .loadProperties(buildFile.getParentFile().getAbsolutePath() + File.separator + "build.properties")); setPersonalProperties(AemDemoUtils.loadProperties(buildFile.getParentFile().getAbsolutePath() + File.separator + "conf" + File.separator + "build-personal.properties")); // Constructing the main frame frameMain = new JFrame(); frameMain.setBounds(100, 100, 700, 530); frameMain.getContentPane().setLayout(null); // Main menu bar for the Frame JMenuBar menuBar = new JMenuBar(); JMenu mnAbout = new JMenu("AEM Demo Machine"); mnAbout.setMnemonic(KeyEvent.VK_A); menuBar.add(mnAbout); JMenuItem mntmDoc = new JMenuItem("Help and Documentation"); mntmDoc.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_H, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmDoc.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties, AemDemoConstants.OPTIONS_DOCUMENTATION)); } }); mnAbout.add(mntmDoc); JMenuItem mntmQuit = new JMenuItem("Quit"); mntmQuit.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_Q, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmQuit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(-1); } }); mnAbout.add(mntmQuit); JMenu mnNew = new JMenu("New"); mnNew.setMnemonic(KeyEvent.VK_N); menuBar.add(mnNew); // New Demo Machine JMenuItem mntmNewDemo = new JMenuItem("Demo Environment"); mntmNewDemo.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmNewDemo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (AemDemo.this.getBuildInProgress()) { JOptionPane.showMessageDialog(null, "A Demo Environment is currently being built. Please wait until it is finished."); } else { final AemDemoNew dialogNew = new AemDemoNew(AemDemo.this); dialogNew.setModal(true); dialogNew.setVisible(true); dialogNew.getDemoBuildName().requestFocus(); ; } } }); mnNew.add(mntmNewDemo); JMenuItem mntmNewOptions = new JMenuItem("Demo Properties"); mntmNewOptions.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_P, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmNewOptions.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final AemDemoOptions dialogOptions = new AemDemoOptions(AemDemo.this); dialogOptions.setModal(true); dialogOptions.setVisible(true); } }); mnNew.add(mntmNewOptions); JMenu mnUpdate = new JMenu("Add-ons"); menuBar.add(mnUpdate); // Sites Add-on JMenu mnSites = new JMenu("Sites"); mnUpdate.add(mnSites); JMenuItem mntmSitesDownloadAddOn = new JMenuItem("Download Add-On"); mntmSitesDownloadAddOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_sites"); } }); mnSites.add(mntmSitesDownloadAddOn); JMenuItem mntmSitesDownloadFP = new JMenuItem("Download Feature Pack (VPN)"); mntmSitesDownloadFP.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_sites_fp"); } }); mnSites.add(mntmSitesDownloadFP); mnSites.addSeparator(); JMenuItem mntmSitesInstallAddOn = new JMenuItem("Install Add-on"); mntmSitesInstallAddOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "sites"); } }); mnSites.add(mntmSitesInstallAddOn); // Assets Add-on JMenu mnAssets = new JMenu("Assets"); mnUpdate.add(mnAssets); JMenuItem mntmAssetsDownloadAddOn = new JMenuItem("Download Add-on"); mntmAssetsDownloadAddOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_assets"); } }); mnAssets.add(mntmAssetsDownloadAddOn); mnAssets.addSeparator(); JMenuItem mntmAssetsInstallAddOn = new JMenuItem("Install Add-on"); mntmAssetsInstallAddOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "assets"); } }); mnAssets.add(mntmAssetsInstallAddOn); // Communities Add-on JMenu mnCommunities = new JMenu("Communities"); mnUpdate.add(mnCommunities); JMenuItem mntmAemCommunitiesUber = new JMenuItem("Download Latest Bundles (VPN)"); mntmAemCommunitiesUber.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_U, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmAemCommunitiesUber.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_communities_bundles"); } }); mnCommunities.add(mntmAemCommunitiesUber); JMenuItem mntmAemCommunitiesFeaturePacks = new JMenuItem("Download Latest Feature Packs (PackageShare)"); mntmAemCommunitiesFeaturePacks.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_communities_fp"); } }); mnCommunities.add(mntmAemCommunitiesFeaturePacks); JMenuItem mntmAemCommunitiesEnablement = new JMenuItem("Download Enablement Demo Site Add-on (4.5GB)"); mntmAemCommunitiesEnablement.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_enablement"); } }); mnCommunities.add(mntmAemCommunitiesEnablement); mnCommunities.addSeparator(); JMenuItem mntmAemCommunitiesAddOn = new JMenuItem("Install Add-on"); mntmAemCommunitiesAddOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "communities"); } }); mnCommunities.add(mntmAemCommunitiesAddOn); // Forms Add-on JMenu mnForms = new JMenu("Forms"); mnUpdate.add(mnForms); JMenuItem mntmAemFormsFP = new JMenuItem("Download Demo Add-on (PackageShare)"); mntmAemFormsFP.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_forms_fp"); } }); mnForms.add(mntmAemFormsFP); mnForms.addSeparator(); JMenuItem mntmAemFormsAddOn = new JMenuItem("Install Add-on"); mntmAemFormsAddOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "forms"); } }); mnForms.add(mntmAemFormsAddOn); // Apps Add-on JMenu mnApps = new JMenu("Apps"); mnUpdate.add(mnApps); JMenuItem mntmAemApps = new JMenuItem("Download Add-on"); mntmAemApps.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_apps"); } }); mnApps.add(mntmAemApps); mnApps.addSeparator(); JMenuItem mntmAemAppsAddOn = new JMenuItem("Install Add-on"); mntmAemAppsAddOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "apps"); } }); mnApps.add(mntmAemAppsAddOn); // Commerce Add-on JMenu mnCommerce = new JMenu("Commerce"); mnUpdate.add(mnCommerce); JMenu mnCommerceDownload = new JMenu("Download Add-on"); mnCommerce.add(mnCommerceDownload); // Commerce EP JMenuItem mnCommerceDownloadEP = new JMenuItem("ElasticPath"); mnCommerceDownloadEP.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_commerce_ep"); } }); mnCommerceDownload.add(mnCommerceDownloadEP); // Commerce WebSphere JMenuItem mnCommerceDownloadWAS = new JMenuItem("WebSphere"); mnCommerceDownloadWAS.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_commerce_websphere"); } }); mnCommerceDownload.add(mnCommerceDownloadWAS); mnCommerce.addSeparator(); JMenuItem mntmAemCommerceAddOn = new JMenuItem("Install Add-on"); mntmAemCommerceAddOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "commerce"); } }); mnCommerce.add(mntmAemCommerceAddOn); mnUpdate.addSeparator(); JMenuItem mntmAemDownloadAll = new JMenuItem("Download All Add-ons"); mntmAemDownloadAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_all"); } }); mnUpdate.add(mntmAemDownloadAll); JMenuItem mntmAemDownloadFromDrive = new JMenuItem("Download Web Page"); mntmAemDownloadFromDrive.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties, AemDemoConstants.OPTIONS_WEBDOWNLOAD)); } }); mnUpdate.add(mntmAemDownloadFromDrive); JMenu mnInfrastructure = new JMenu("Infrastructure"); menuBar.add(mnInfrastructure); JMenu mnMongo = new JMenu("MongoDB"); JMenuItem mntmInfraMongoDB = new JMenuItem("Download"); mntmInfraMongoDB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_mongo"); } }); mnMongo.add(mntmInfraMongoDB); JMenuItem mntmInfraMongoDBInstall = new JMenuItem("Install"); mntmInfraMongoDBInstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "install_mongo"); } }); mnMongo.add(mntmInfraMongoDBInstall); mnMongo.addSeparator(); JMenuItem mntmInfraMongoDBStart = new JMenuItem("Start"); mntmInfraMongoDBStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "mongo_start"); } }); mnMongo.add(mntmInfraMongoDBStart); JMenuItem mntmInfraMongoDBStop = new JMenuItem("Stop"); mntmInfraMongoDBStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "mongo_stop"); } }); mnMongo.add(mntmInfraMongoDBStop); mnInfrastructure.add(mnMongo); // SOLR options JMenu mnSOLR = new JMenu("SOLR"); JMenuItem mntmInfraSOLR = new JMenuItem("Download"); mntmInfraSOLR.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_solr"); } }); mnSOLR.add(mntmInfraSOLR); JMenuItem mntmInfraSOLRInstall = new JMenuItem("Install"); mntmInfraSOLRInstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "install_solr"); } }); mnSOLR.add(mntmInfraSOLRInstall); mnSOLR.addSeparator(); JMenuItem mntmInfraSOLRStart = new JMenuItem("Start"); mntmInfraSOLRStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "solr_start"); } }); mnSOLR.add(mntmInfraSOLRStart); JMenuItem mntmInfraSOLRStop = new JMenuItem("Stop"); mntmInfraSOLRStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "solr_stop"); } }); mnSOLR.add(mntmInfraSOLRStop); mnInfrastructure.add(mnSOLR); // MySQL options JMenu mnMySQL = new JMenu("MySQL"); JMenuItem mntmInfraMysql = new JMenuItem("Download"); mntmInfraMysql.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_mysql"); } }); mnMySQL.add(mntmInfraMysql); JMenuItem mntmInfraMysqlInstall = new JMenuItem("Install"); mntmInfraMysqlInstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "install_mysql"); } }); mnMySQL.add(mntmInfraMysqlInstall); mnMySQL.addSeparator(); JMenuItem mntmInfraMysqlStart = new JMenuItem("Start"); mntmInfraMysqlStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "mysql_start"); } }); mnMySQL.add(mntmInfraMysqlStart); JMenuItem mntmInfraMysqlStop = new JMenuItem("Stop"); mntmInfraMysqlStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "mysql_stop"); } }); mnMySQL.add(mntmInfraMysqlStop); mnInfrastructure.add(mnMySQL); // FFMPEPG options JMenu mnFFMPEG = new JMenu("FFMPEG"); JMenuItem mntmInfraFFMPEG = new JMenuItem("Download"); mntmInfraFFMPEG.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_ffmpeg"); } }); mnFFMPEG.add(mntmInfraFFMPEG); JMenuItem mntmInfraFFMPEGInstall = new JMenuItem("Install"); mntmInfraFFMPEGInstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "install_ffmpeg"); } }); mnFFMPEG.add(mntmInfraFFMPEGInstall); mnInfrastructure.add(mnFFMPEG); // Apache James options JMenu mnJames = new JMenu("James SMTP"); JMenuItem mnJamesStart = new JMenuItem("Start"); mnJamesStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "james_start"); } }); mnJames.add(mnJamesStart); JMenuItem mnJamesStop = new JMenuItem("Stop"); mnJamesStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "james_stop"); } }); mnJames.add(mnJamesStop); mnInfrastructure.add(mnJames); mnInfrastructure.addSeparator(); JMenuItem mntmInfraInstall = new JMenuItem("All in One Setup"); mntmInfraInstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "infrastructure"); } }); mnInfrastructure.add(mntmInfraInstall); JMenu mnOther = new JMenu("Other"); menuBar.add(mnOther); JMenu mntmAemDownload = new JMenu("AEM & License files (VPN)"); JMenuItem mntmAemDownloadAEM61 = new JMenuItem("Download AEM 6.1"); mntmAemDownloadAEM61.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_aem61"); } }); mntmAemDownload.add(mntmAemDownloadAEM61); JMenuItem mntmAemDownloadAEM60 = new JMenuItem("Download AEM 6.0"); mntmAemDownloadAEM60.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_aem60"); } }); mntmAemDownload.add(mntmAemDownloadAEM60); JMenuItem mntmAemDownloadCQ561 = new JMenuItem("Download CQ 5.6.1"); mntmAemDownloadCQ561.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_cq561"); } }); mntmAemDownload.add(mntmAemDownloadCQ561); JMenuItem mntmAemDownloadCQ56 = new JMenuItem("Download CQ 5.6"); mntmAemDownloadCQ56.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_cq56"); } }); mntmAemDownload.add(mntmAemDownloadCQ56); JMenuItem mntmAemDownloadOthers = new JMenuItem("Other Releases & License files"); mntmAemDownloadOthers.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties, AemDemoConstants.OPTIONS_DOWNLOAD)); } }); mntmAemDownload.add(mntmAemDownloadOthers); mnOther.add(mntmAemDownload); JMenuItem mntmAemSnapshot = new JMenuItem("Download Latest AEM Snapshot (VPN)"); mntmAemSnapshot.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_T, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmAemSnapshot.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_snapshot"); } }); mnOther.add(mntmAemSnapshot); JMenuItem mntmAemDemoMachine = new JMenuItem("Download Latest AEM Demo Machine"); mntmAemDemoMachine.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmAemDemoMachine.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties, AemDemoConstants.OPTIONS_DEMODOWNLOAD)); } }); mnOther.add(mntmAemDemoMachine); // Adding the menu bar frameMain.setJMenuBar(menuBar); // Adding other form elements JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(24, 184, 650, 230); frameMain.getContentPane().add(scrollPane); final JTextArea textArea = new JTextArea(""); textArea.setEditable(false); scrollPane.setViewportView(textArea); // List of demo machines available JScrollPane scrollDemoList = new JScrollPane(); scrollDemoList.setBounds(24, 55, 208, 100); frameMain.getContentPane().add(scrollDemoList); listModelDemoMachines = AemDemoUtils.listDemoMachines(buildFile.getParentFile().getAbsolutePath()); listDemoMachines = new JList(listModelDemoMachines); scrollDemoList.setViewportView(listDemoMachines); // Capturing the output stream of ANT commands AemDemoOutputStream out = new AemDemoOutputStream(textArea); System.setOut(new PrintStream(out)); JButton btnStart = new JButton("Start"); btnStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "start"); } }); btnStart.setBounds(250, 50, 117, 29); frameMain.getContentPane().add(btnStart); // Set Start as the default button JRootPane rootPane = SwingUtilities.getRootPane(btnStart); rootPane.setDefaultButton(btnStart); JButton btnInfo = new JButton("Details"); btnInfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "version"); AemDemoUtils.antTarget(AemDemo.this, "configuration"); } }); btnInfo.setBounds(250, 80, 117, 29); frameMain.getContentPane().add(btnInfo); JButton btnStop = new JButton("Stop"); btnStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "stop"); } }); btnStop.setBounds(500, 50, 117, 29); frameMain.getContentPane().add(btnStop); JButton btnExit = new JButton("Exit"); btnExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(-1); } }); btnExit.setBounds(550, 429, 117, 29); frameMain.getContentPane().add(btnExit); JButton btnClear = new JButton("Clear"); btnClear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textArea.setText(""); } }); btnClear.setBounds(40, 429, 117, 29); frameMain.getContentPane().add(btnClear); JButton btnBackup = new JButton("Backup"); btnBackup.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "backup"); } }); btnBackup.setBounds(500, 80, 117, 29); frameMain.getContentPane().add(btnBackup); JButton btnRestore = new JButton("Restore"); btnRestore.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "restore"); } }); btnRestore.setBounds(500, 110, 117, 29); frameMain.getContentPane().add(btnRestore); JButton btnDelete = new JButton("Delete"); btnDelete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "uninstall"); } }); btnDelete.setBounds(500, 140, 117, 29); frameMain.getContentPane().add(btnDelete); JLabel lblSelectYourDemo = new JLabel("Select your Demo Environment"); lblSelectYourDemo.setBounds(24, 31, 219, 16); frameMain.getContentPane().add(lblSelectYourDemo); JLabel lblCommandOutput = new JLabel("Command Output"); lblCommandOutput.setBounds(24, 164, 160, 16); frameMain.getContentPane().add(lblCommandOutput); // Launching the download tracker task AemDemoDownload aemDownload = new AemDemoDownload(AemDemo.this); ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); executor.scheduleAtFixedRate(aemDownload, 0, 5, TimeUnit.SECONDS); }
From source file:gdt.jgui.entity.webset.JWeblinkEditor.java
/** * Get the context menu./* w w w .j a va 2 s .com*/ * @return the context menu. */ @Override public JMenu getContextMenu() { JMenu menu = new JMenu("Context"); JMenuItem doneItem = new JMenuItem("Done"); doneItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { save(); if (requesterResponseLocator$ != null) { try { byte[] ba = Base64.decodeBase64(requesterResponseLocator$); String responseLocator$ = new String(ba, "UTF-8"); JConsoleHandler.execute(console, responseLocator$); } catch (Exception ee) { Logger.getLogger(getClass().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) { try { browseUrl(console, locator$); } catch (Exception ee) { Logger.getLogger(getClass().getName()).info(ee.toString()); } } }); menu.add(cancelItem); menu.addSeparator(); JMenuItem browseItem = new JMenuItem("Browse"); browseItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Desktop.getDesktop().browse(new URI(addressField.getText())); } catch (Exception ee) { Logger.getLogger(JWeblinkEditor.class.getName()).info(ee.toString()); } } }); menu.add(browseItem); return menu; }
From source file:com.pingtel.sipviewer.SIPViewerFrame.java
protected void initMenu() { JMenu menu; JMenu submenu;//from w w w.j a v a2 s . co m JMenuItem menuItem; JRadioButtonMenuItem rbMenuItem; // Create the menu bar. JMenuBar menuBar = new JMenuBar(); this.setJMenuBar(menuBar); // Build the File menu. menu = new JMenu("File"); menu.setMnemonic(KeyEvent.VK_F); menuBar.add(menu); // Add the load-file items to the File menu. menuItem = new JMenuItem(); menuItem.setAction(new icOpenFileAction()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.ALT_MASK)); menuItem.setMnemonic(KeyEvent.VK_F); menu.add(menuItem); menuItem = new JMenuItem(); menuItem.setAction(new icImportSyslogAction()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, ActionEvent.ALT_MASK)); menuItem.setMnemonic(KeyEvent.VK_Y); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(); menuItem.setAction(new icSaveAsAction()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.ALT_MASK)); menuItem.setMnemonic(KeyEvent.VK_S); menu.add(menuItem); menu.addSeparator(); // Add the reload item to the File menu. menuItem = new JMenuItem(); menuItem.setAction(new icReloadAction()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.ALT_MASK)); menuItem.setMnemonic(KeyEvent.VK_R); menu.add(menuItem); menu.addSeparator(); // Add the quit item to the File menu. menuItem = new JMenuItem(); menuItem.setAction(new icQuitAction()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.ALT_MASK)); menuItem.setMnemonic(KeyEvent.VK_Q); menu.add(menuItem); // Build the Options menu. menu = new JMenu("Options"); menu.setMnemonic(KeyEvent.VK_O); menuBar.add(menu); // Add the split/single screen mode to the options menu menuItem = new JMenuItem(); menuItem.setAction(new icScreenModeAction()); menuItem.setMnemonic(KeyEvent.VK_M); menu.add(menuItem); menu.addSeparator(); // Add the show all dialogs option to the options menu menuItem = new JMenuItem(); menuItem.setAction(new icShowAllDialogsAction()); menuItem.setMnemonic(KeyEvent.VK_D); menu.add(menuItem); menu.addSeparator(); // Add the Time Zone Selection Time submenu submenu = new JMenu("Time Zone Setting"); submenu.setMnemonic(KeyEvent.VK_Z); ButtonGroup timeZoneGroup = new ButtonGroup(); // Set Time Zone to Local Time Zone m_localTimeZone = new JRadioButtonMenuItem(); m_localTimeZone.setAction(new icSetTimeToLocalZone()); m_localTimeZone.setMnemonic(KeyEvent.VK_L); timeZoneGroup.add(m_localTimeZone); m_localTimeZone.setSelected(true); submenu.add(m_localTimeZone); // Set Time Zone to UTC Time Zone m_utcTimeZone = new JRadioButtonMenuItem(); m_utcTimeZone.setAction(new icSetTimeToUTCZone()); m_utcTimeZone.setMnemonic(KeyEvent.VK_U); timeZoneGroup.add(m_utcTimeZone); submenu.add(m_utcTimeZone); menu.add(submenu); // Add the show/hide time index column menuItem = new JMenuItem(); menuItem.setAction(new icTimeVisibilityAction()); menuItem.setMnemonic(KeyEvent.VK_V); menu.add(menuItem); // Add the Time Display Format submenu submenu = new JMenu("Time Display Format"); submenu.setMnemonic(KeyEvent.VK_T); ButtonGroup group = new ButtonGroup(); m_dateAndTimeFormat = new JRadioButtonMenuItem(); m_dateAndTimeFormat.setAction(new icDateAndTimeAction()); m_dateAndTimeFormat.setMnemonic(KeyEvent.VK_I); group.add(m_dateAndTimeFormat); submenu.add(m_dateAndTimeFormat); m_defaultTimeFormat = new JRadioButtonMenuItem(); m_defaultTimeFormat.setAction(new icTimeOfDay()); m_defaultTimeFormat.setMnemonic(KeyEvent.VK_E); m_defaultTimeFormat.setSelected(true); group.add(m_defaultTimeFormat); submenu.add(m_defaultTimeFormat); m_sincePreviousFormat = new JRadioButtonMenuItem(); m_sincePreviousFormat.setAction(new icSincePrevious()); m_sincePreviousFormat.setMnemonic(KeyEvent.VK_P); group.add(m_sincePreviousFormat); submenu.add(m_sincePreviousFormat); m_sinceBeginningFormat = new JRadioButtonMenuItem(); m_sinceBeginningFormat.setAction(new icSinceBeginning()); m_sinceBeginningFormat.setMnemonic(KeyEvent.VK_B); group.add(m_sinceBeginningFormat); submenu.add(m_sinceBeginningFormat); m_sinceKeyIndexFormat = new JRadioButtonMenuItem(); m_sinceKeyIndexFormat.setAction(new icSinceKeyIndex()); m_sinceKeyIndexFormat.setMnemonic(KeyEvent.VK_K); group.add(m_sinceKeyIndexFormat); submenu.add(m_sinceKeyIndexFormat); menu.add(submenu); // Build the Help menu. menu = new JMenu("Help"); menu.setMnemonic(KeyEvent.VK_H); menuBar.add(menu); // Add the items to the File menu. menuItem = new JMenuItem(); menuItem.setAction(new icAboutAction()); menu.add(menuItem); }
From source file:com.AandR.beans.plotting.imagePlotPanel.CanvasPanel.java
private void createPopupMenu() { popupMenu = new JPopupMenu(); popupMenu.add(createPopupMenuItem("Toggle Log Plot", null, KeyStroke.getKeyStroke(KeyEvent.VK_L, 0))); popupMenu.add(createPopupMenuItem("Slice Here", null, KeyStroke.getKeyStroke(KeyEvent.VK_C, 10))); popupMenu.addSeparator();//from www.jav a 2s.co m JMenu navigateMenu = new JMenu("Navigate"); navigateMenu.add(createPopupMenuItem("View First Frame", null, KeyStroke.getKeyStroke(KeyEvent.VK_F, 2))); navigateMenu .add(createPopupMenuItem("View Previous Frame", null, KeyStroke.getKeyStroke(KeyEvent.VK_P, 2))); navigateMenu .add(createPopupMenuItem("Choose Frame To View", null, KeyStroke.getKeyStroke(KeyEvent.VK_C, 2))); navigateMenu.add(createPopupMenuItem("View Next Frame", null, KeyStroke.getKeyStroke(KeyEvent.VK_N, 2))); navigateMenu.add(createPopupMenuItem("View Last Frame", null, KeyStroke.getKeyStroke(KeyEvent.VK_L, 2))); popupMenu.add(navigateMenu); popupMenu.addSeparator(); popupMenu.add(createPopupMenuItem("Set Zoom Level", null, KeyStroke.getKeyStroke(KeyEvent.VK_Z, 2))); popupMenu.add(createPopupMenuItem("Set Min/Max", null, KeyStroke.getKeyStroke(KeyEvent.VK_R, 2))); popupMenu.add(createPopupMenuItem("Set Physical Extent", null, KeyStroke.getKeyStroke(KeyEvent.VK_E, 2))); popupMenu.addSeparator(); popupMenu.add(createPopupMenuItem("Recenter on Viewport", null, KeyStroke.getKeyStroke(KeyEvent.VK_C, 0))); popupMenu.addSeparator(); popupMenu.add(createPopupMenuItem("Set Colormap", null, KeyStroke.getKeyStroke(KeyEvent.VK_M, 2))); popupMenu.addSeparator(); JMenu overlayMenu = new JMenu("Overlays"); overlayMenu.add(createPopupMenuItem("Add Text Overlay", null, KeyStroke.getKeyStroke(KeyEvent.VK_T, 2))); overlayMenu.add(createPopupMenuItem("Add Shape Overlay", null, KeyStroke.getKeyStroke(KeyEvent.VK_O, 2))); overlayMenu.add(createPopupMenuItem("Add Annulus Overlay", null, KeyStroke.getKeyStroke(KeyEvent.VK_U, 2))); overlayMenu.add(createPopupMenuItem("Add Arrow Overlay", null, KeyStroke.getKeyStroke(KeyEvent.VK_A, 2))); popupMenu.add(overlayMenu); popupMenu.addSeparator(); JMenu pngMenu = new JMenu("To PNG"); pngMenu.add(createPopupMenuItem("Export Original Image", null, KeyStroke.getKeyStroke(KeyEvent.VK_S, 10))); pngMenu.add(createPopupMenuItem("Export Viewport Image", null, KeyStroke.getKeyStroke(KeyEvent.VK_S, 2))); pngMenu.addSeparator(); pngMenu.add(createPopupMenuItem("Export Viewport Series", null, KeyStroke.getKeyStroke(KeyEvent.VK_S, 8))); JMenu pdfMenu = new JMenu("To PDF"); pdfMenu.add(createPopupMenuItem("Export Original Image", null, KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.SHIFT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK))); pdfMenu.add(createPopupMenuItem("Export Viewport Image", null, KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.ALT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK))); JMenu exportMenu = new JMenu("Export"); exportMenu.add(pngMenu); exportMenu.add(pdfMenu); popupMenu.add(exportMenu); popupMenu.addSeparator(); JMenu losslessMenu = new JMenu("Lossless Modifications"); losslessMenu.add(createPopupMenuItem("Flip Horizontally", null, KeyStroke.getKeyStroke(KeyEvent.VK_H, 10))); losslessMenu.add(createPopupMenuItem("Flip Vertically", null, KeyStroke.getKeyStroke(KeyEvent.VK_V, 10))); losslessMenu.addSeparator(); losslessMenu.add(createPopupMenuItem("Rotate +90", null, KeyStroke.getKeyStroke(KeyEvent.VK_R, 10))); losslessMenu.add(createPopupMenuItem("Rotate -90", null, KeyStroke.getKeyStroke(KeyEvent.VK_L, 10))); popupMenu.add(losslessMenu); }