List of usage examples for javax.swing JMenuBar JMenuBar
public JMenuBar()
From source file:biomine.bmvis2.Vis.java
public JMenuBar getDefaultMenu() { JMenuBar bar = new JMenuBar(); Menus m = Menus.getDefaultMenuInstance(this); m.buildMenuBar(bar, new ArrayList<JavaScriptConsole>()); return bar;/*from w w w. java2 s. c om*/ }
From source file:edu.ku.brc.specify.tools.schemalocale.SchemaLocalizerFrame.java
/** * /*w w w. j a va 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:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSwing.CFAsteriskSwingClusterFinderJInternalFrame.java
public JMenuBar getFinderMenuBar() { if (finderMenuBar == null) { JMenuItem menuItem;//from w w w. ja v a 2 s . co m finderMenuBar = new JMenuBar(); menuFile = new JMenu("File"); actionViewSelected = new ActionViewSelectedCluster(); menuItem = new JMenuItem(actionViewSelected); menuFile.add(menuItem); actionEditSelected = new ActionEditSelectedCluster(); menuItem = new JMenuItem(actionEditSelected); menuFile.add(menuItem); actionClose = new ActionClose(); menuItem = new JMenuItem(actionClose); menuFile.add(menuItem); finderMenuBar.add(menuFile); } return (finderMenuBar); }
From source file:AltiConsole.AltiConsoleMainScreen.java
/** * Constructs main screen of the application. * /*from w ww . j ava 2 s . c o m*/ * @param title * the frame title. */ public AltiConsoleMainScreen(final String title) { super(title); trans = Application.getTranslator(); // //////// Menu code starts her ////////////// // File fileMenu = new JMenu(); fileMenu.setText(trans.get("AltiConsoleMainScreen.File")); // Load data loadDataMenuItem = new JMenuItem(); loadDataMenuItem.setText(trans.get("AltiConsoleMainScreen.RetrieveFlightData")); loadDataMenuItem.setActionCommand("RETRIEVE_FLIGHT"); loadDataMenuItem.addActionListener(this); eraseAllDataMenuItem = new JMenuItem(); eraseAllDataMenuItem.setText(trans.get("AltiConsoleMainScreen.EraseFlightData")); eraseAllDataMenuItem.setActionCommand("ERASE_FLIGHT"); eraseAllDataMenuItem.addActionListener(this); // Save as saveASMenuItem = new JMenuItem(); saveASMenuItem.setText(trans.get("AltiConsoleMainScreen.saveFlightData")); saveASMenuItem.setActionCommand("SAVE_FLIGHT"); saveASMenuItem.addActionListener(this); // Exit exitMenuItem = new JMenuItem(); exitMenuItem.setText(trans.get("AltiConsoleMainScreen.Exit")); exitMenuItem.setActionCommand("EXIT"); exitMenuItem.addActionListener(this); fileMenu.add(saveASMenuItem); fileMenu.add(loadDataMenuItem); fileMenu.add(eraseAllDataMenuItem); fileMenu.add(exitMenuItem); // Option menu optionMenu = new JMenu(trans.get("AltiConsoleMainScreen.Option")); preferencesMenuItem = new JMenuItem(trans.get("AltiConsoleMainScreen.Preferences")); preferencesMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("pref\n"); Preferences.showPreferences(AltiConsoleMainScreen.this); //LicenseDialog.showPreferences(AltiConsoleMainScreen.this); System.out.println("change units\n"); String Units; System.out.println(UserPref.getAppUnits()); if (Utils.equals(UserPref.getAppUnits(), "Unit.Metrics")) Units = trans.get("Unit.Metrics"); else Units = trans.get("Unit.Imperial"); chart.getXYPlot().getRangeAxis() .setLabel(trans.get("AltiConsoleMainScreen.altitude") + " (" + Units + ")"); if (Serial.getConnected()) { RetrievingFlight(); } } }); optionMenu.add(preferencesMenuItem); // Configuration menu altiConfigMenu = new JMenu(trans.get("AltiConsoleMainScreen.ConfigAltimeter")); retrieveAltiConfigMenuItem = new JMenuItem(trans.get("AltiConsoleMainScreen.RetrieveAltiConfig")); retrieveAltiConfigMenuItem.setActionCommand("RETRIEVE_ALTI_CFG"); retrieveAltiConfigMenuItem.addActionListener(this); altiConfigMenu.add(retrieveAltiConfigMenuItem); uploadFirmwareMenuItem = new JMenuItem(trans.get("AltiConsoleMainScreen.UploadFirmware")); uploadFirmwareMenuItem.setActionCommand("UPLOAD_FIRMWARE"); uploadFirmwareMenuItem.addActionListener(this); altiConfigMenu.add(uploadFirmwareMenuItem); // Help helpMenu = new JMenu(trans.get("AltiConsoleMainScreen.Help")); jJMenuBar = new JMenuBar(); // Manual onLineHelpMenuItem = new JMenuItem(trans.get("AltiConsoleMainScreen.onLineHelp")); onLineHelpMenuItem.setActionCommand("ON_LINE_HELP"); onLineHelpMenuItem.addActionListener(this); // license licenseMenuItem = new JMenuItem(trans.get("AltiConsoleMainScreen.license")); licenseMenuItem.setActionCommand("LICENSE"); licenseMenuItem.addActionListener(this); // AboutScreen aboutMenuItem = new JMenuItem(); aboutMenuItem.setText(trans.get("AltiConsoleMainScreen.About")); aboutMenuItem.setActionCommand("ABOUT"); aboutMenuItem.addActionListener(this); helpMenu.add(onLineHelpMenuItem); helpMenu.add(licenseMenuItem); helpMenu.add(aboutMenuItem); jJMenuBar.add(fileMenu); jJMenuBar.add(optionMenu); jJMenuBar.add(altiConfigMenu); jJMenuBar.add(helpMenu); this.setJMenuBar(jJMenuBar); // ///// end of Menu code // Button retrieveFlights = new JButton(); retrieveFlights.setText(trans.get("AltiConsoleMainScreen.RetrieveFlights")); retrieveFlights.setActionCommand("RETRIEVE_FLIGHT"); retrieveFlights.addActionListener(this); retrieveFlights.setToolTipText(trans.get("AltiConsoleMainScreen.ttipRetrieveFlight")); // combo serial rate String[] serialRateStrings = { "300", "1200", "2400", "4800", "9600", "14400", "19200", "28800", "38400", "57600", "115200" }; serialRatesLabel = new JLabel(trans.get("AltiConsoleMainScreen.comPortSpeed") + " "); serialRates = new JComboBox(); System.out.println(UserPref.getDefComSpeed() + "\n"); for (int i = 0; i < serialRateStrings.length; i++) { serialRates.addItem(serialRateStrings[i]); if (Utils.equals(UserPref.getDefComSpeed(), serialRateStrings[i])) { serialRates.setSelectedIndex(i); } } serialRates.setToolTipText(trans.get("AltiConsoleMainScreen.ttipChoosePortSpeed")); comPortsLabel = new JLabel(trans.get("AltiConsoleMainScreen.port") + " "); comPorts = new JComboBox(); comPorts.setActionCommand("comPorts"); comPorts.addActionListener(this); comPorts.setToolTipText(trans.get("AltiConsoleMainScreen.ttipChooseAltiport")); listData = new DefaultListModel(); flightList = new JXList(listData); flightList.addListSelectionListener(new ValueReporter()); JPanel TopPanelLeft = new JPanel(); TopPanelLeft.setLayout(new BorderLayout()); TopPanelLeft.add(comPortsLabel, BorderLayout.WEST); TopPanelLeft.add(comPorts, BorderLayout.EAST); JPanel TopPanelMiddle = new JPanel(); TopPanelMiddle.setLayout(new BorderLayout()); TopPanelMiddle.add(retrieveFlights, BorderLayout.WEST); JPanel TopPanelRight = new JPanel(); TopPanelRight.setLayout(new BorderLayout()); TopPanelRight.add(serialRatesLabel, BorderLayout.WEST); TopPanelRight.add(serialRates, BorderLayout.EAST); JPanel TopPanel = new JPanel(); TopPanel.setLayout(new BorderLayout()); TopPanel.add(TopPanelRight, BorderLayout.EAST); TopPanel.add(TopPanelMiddle, BorderLayout.CENTER); TopPanel.add(TopPanelLeft, BorderLayout.WEST); JPanel MiddlePanel = new JPanel(); MiddlePanel.setLayout(new BorderLayout()); MiddlePanel.add(TopPanel, BorderLayout.NORTH); MiddlePanel.add(flightList, BorderLayout.WEST); String Units; if (Utils.equals(UserPref.getAppUnits(), "Unit.Metrics")) Units = trans.get("Unit.Metrics"); else Units = trans.get("Unit.Imperial"); chart = ChartFactory.createXYLineChart(trans.get("AltiConsoleMainScreen.Title"), trans.get("AltiConsoleMainScreen.time"), trans.get("AltiConsoleMainScreen.altitude") + " (" + Units + ")", null); chart.setBackgroundPaint(Color.white); System.out.println(chart.getSubtitle(0)); this.plot = chart.getXYPlot(); this.plot.setBackgroundPaint(Color.lightGray); this.plot.setDomainGridlinePaint(Color.white); this.plot.setRangeGridlinePaint(Color.white); final ValueAxis axis = this.plot.getDomainAxis(); axis.setAutoRange(true); final NumberAxis rangeAxis2 = new NumberAxis("Range Axis 2"); rangeAxis2.setAutoRangeIncludesZero(false); final ChartPanel chartPanel = new ChartPanel(chart); MiddlePanel.add(chartPanel, BorderLayout.CENTER); JPanel InfoPanel = new JPanel(new MigLayout("fill")); InfoPanel.add(new JLabel(trans.get("AltiConsoleMainScreen.ApogeeAltitude")), "gapright para"); apogeeAltitudeLabel = new JLabel(); InfoPanel.add(apogeeAltitudeLabel, "growx"); InfoPanel.add(new JLabel(trans.get("AltiConsoleMainScreen.MainAltitude")), "gapright para"); mainAltitudeLabel = new JLabel(); InfoPanel.add(mainAltitudeLabel, "growx"); flightNbrLabel = new JLabel(); InfoPanel.add(new JLabel(trans.get("AltiConsoleMainScreen.NbrOfPoint")), "growx"); nbrPointLabel = new JLabel(); InfoPanel.add(nbrPointLabel, "wrap rel,growx"); txtLog = new JTextArea(5, 70); txtLog.setEditable(false); txtLog.setAutoscrolls(true); scrollPane = new JScrollPane(txtLog); scrollPane.setAutoscrolls(true); // BottomPanel.add(scrollPane, BorderLayout.WEST); InfoPanel.add(scrollPane, "span"); // MiddlePanel.add(BottomPanel, BorderLayout.SOUTH); MiddlePanel.add(InfoPanel, BorderLayout.SOUTH); setContentPane(MiddlePanel); try { try { Serial = new AltimeterSerial(this); Serial.searchForPorts(); } catch (UnsatisfiedLinkError e) { System.out.println("USB Library rxtxSerial.dll Not Found"); System.out.println("Exception:" + e.toString() + ":" + e.getMessage()); System.out.println(e.toString()); JOptionPane.showMessageDialog(null, "You must copy the appropriate rxtxSerial.dll \n " + "to your local 32 bit or 64 bitjava JRE installation\n\n" + " .../arduino-1.0.1-windows/arduino-1.0.1/rxtxSerial.dll\n" + "to\n C:/Program Files (x86)/Java/jre7/bin/rxtxSerial.dll\n" + "also right click Properties->Unblock", trans.get("AltiConsoleMainScreen.InstallationProblem"), JOptionPane.WARNING_MESSAGE); } } catch (NoClassDefFoundError e) { System.out.println("Missing RXTXcomm.jar in java installation"); System.out.println("Exception:" + e.toString() + ":" + e.getMessage()); System.out.println(e.toString()); JOptionPane.showMessageDialog(null, "You must copy RXTXcomm.jar from the Arduino software\n " + "to your local 32 bit java JRE installation\n\n" + " .../arduino-1.0.1-windows/arduino-1.0.1/lib/RXTXcomm.jar\n" + "to\n C:/Program Files (x86)/Java/jre7/lib/ext/RXTXcomm.jar\n" + "also right click Properties->Unblock", trans.get("AltiConsoleMainScreen.InstallationProblem"), JOptionPane.WARNING_MESSAGE); } }
From source file:com.diversityarrays.dal.server.ServerGui.java
public ServerGui(Image serverIconImage, IDalServer svr, DalServerFactory factory, File wwwRoot, DalServerPreferences prefs) {/*from ww w. j a v a2 s. c om*/ this.serverIconImage = serverIconImage; this.dalServerFactory = factory; this.wwwRoot = wwwRoot; this.preferences = prefs; JMenuBar menuBar = new JMenuBar(); JMenu serverMenu = new JMenu("Server"); menuBar.add(serverMenu); serverMenu.add(serverStartAction); serverMenu.add(serverStopAction); serverMenu.add(exitAction); JMenu commandMenu = new JMenu("Command"); menuBar.add(commandMenu); commandMenu.add(doSql); JMenu urlMenu = new JMenu("URL"); menuBar.add(urlMenu); urlMenu.add(new JMenuItem(copyDalUrlAction)); urlMenu.add(new JMenuItem(showDalUrlQRcodeAction)); setJMenuBar(menuBar); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); messages.setFont(GuiUtil.createMonospacedFont(12)); messages.setEditable(false); setServer(svr); quietOption.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean q = quietOption.isSelected(); if (server != null) { server.setQuiet(q); } } }); JScrollPane scrollPane = new JScrollPane(messages, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); final JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar(); JButton clear = new JButton(new AbstractAction("Clear") { @Override public void actionPerformed(ActionEvent e) { messages.setText(""); } }); final boolean[] follow = new boolean[] { true }; final JCheckBox followTail = new JCheckBox("Follow", follow[0]); followTail.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { follow[0] = followTail.isSelected(); } }); final OutputStream os = new OutputStream() { @Override public void write(int b) throws IOException { char ch = (char) b; messages.append(new Character(ch).toString()); if (ch == '\n' && follow[0]) { verticalScrollBar.setValue(verticalScrollBar.getMaximum()); } } }; TeePrintStream pso = new TeePrintStream(System.out, os); TeePrintStream pse = new TeePrintStream(System.err, os); System.setErr(pse); System.setOut(pso); Box box = Box.createHorizontalBox(); box.add(clear); box.add(followTail); box.add(quietOption); box.add(Box.createHorizontalGlue()); JPanel bottom = new JPanel(new BorderLayout()); bottom.add(BorderLayout.NORTH, box); bottom.add(BorderLayout.SOUTH, statusInfoLine); Container cp = getContentPane(); cp.add(BorderLayout.CENTER, scrollPane); cp.add(BorderLayout.SOUTH, bottom); pack(); setSize(640, 480); final MemoryUsageMonitor mum = new MemoryUsageMonitor(); mum.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { statusInfoLine.setMessage(mum.getMemoryUsage()); } }); if (server == null) { // If initial server is null, allow user to specify addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { removeWindowListener(this); serverStartAction.actionPerformed(null); } }); } else { addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { removeWindowListener(this); ensureDatabaseInitialisedThenStartServer(); } }); } }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
private void menuBarInitializations() { menuBarMain = new JMenuBar(); this.setJMenuBar(menuBarMain); menuFile = new JMenu("File"); menuBarMain.add(menuFile);/*from w w w . ja v a2 s . c o m*/ menuItemOpen = new JMenuItem("Open mzXML"); menuFile.add(menuItemOpen); menuItemSaveImage = new JMenuItem("Save Chromatogram"); menuItemQuit = new JMenuItem("Quit"); menuItemLoadTSV = new JMenuItem("Load TSV table"); menuFile.add(menuItemLoadTSV); menuFile.add(menuItemSaveImage); menuFile.add(menuItemQuit); menuOptions = new JMenu("Options"); menuItemSICtolerance = new JMenuItem("SIC Tolerance"); menuOptions.add(menuItemSICtolerance); menuItemPrecDiscTol = new JMenuItem("Precursor Tolerance"); menuOptions.add(menuItemPrecDiscTol); menuItemDaughterDiscTol = new JMenuItem("Product Tolerance"); menuOptions.add(menuItemDaughterDiscTol); menuItemTraceAllFragments = new JMenuItem("Trace Chromats"); menuOptions.add(menuItemTraceAllFragments); menuItemChangeStrategy = new JMenuItem("Curve Strategy"); menuOptions.add(menuItemChangeStrategy); menuItemSyncLH = new JMenuItem("Synchronize L/H label elution regions"); menuOptions.add(menuItemSyncLH); menuItemPMin = new JMenuItem("Refilter Min Peak Height"); menuOptions.add(menuItemPMin); menuItemAMin = new JMenuItem("Refilter Min Curve Area"); menuOptions.add(menuItemAMin); menuBarMain.add(menuOptions); menuHelp = new JMenu("Help"); menuItemArguments = new JMenuItem("Java commandline options"); menuItemOptions = new JMenuItem("Options help"); menuHelp.add(menuItemOptions); menuItemDefinitions = new JMenuItem("Definitions"); menuHelp.add(menuItemDefinitions); menuItemTips = new JMenuItem("User Tips"); menuHelp.add(menuItemTips); menuHelp.add(menuItemArguments); menuBarMain.add(menuHelp); }
From source file:org.fhaes.fhsamplesize.view.FHSampleSize.java
/** * Set up the Menu bar using actions wherever possible. *///from ww w . ja va 2 s.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:kr.ac.kaist.swrc.jhannanum.demo.GUIDemo.java
/** * Sets the GUI up and launch the demo./*from ww w. ja v a2 s .c o m*/ */ public void run() { /////////////////////////////////////////////////////////////////// // Basic setting for the mainFrame /////////////////////////////////////////////////////////////////// mainFrame = new JFrame(); Toolkit kit = mainFrame.getToolkit(); Dimension windowSize = kit.getScreenSize(); mainFrame.setBounds(windowSize.width / 20, windowSize.height / 20, windowSize.width * 18 / 20, windowSize.height * 18 / 20); mainFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); mainFrame.setTitle("HanNanum Korean Morphological Analyzer - A Plug-in Component based System (GUI Demo)"); Font font = new Font("MonoSpaced", Font.PLAIN, 12); UIManager.put("TextArea.font", font); /////////////////////////////////////////////////////////////////// // Layout setting for the mainFrame /////////////////////////////////////////////////////////////////// mainFrame.setLayout(new BorderLayout()); mainFrame.getContentPane().add(createPaneCenter(), BorderLayout.CENTER); mainFrame.getContentPane().add(createPaneNorth(), BorderLayout.NORTH); /////////////////////////////////////////////////////////////////// // Menu Setting /////////////////////////////////////////////////////////////////// menuBar = new JMenuBar(); menuFile = new JMenu("File"); menuItemFileOpen = new JMenuItem("Open", KeyEvent.VK_O); menuHelp = new JMenu("Help"); menuItemHelp = new JMenuItem("Help", KeyEvent.VK_H); menuItemFileOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.ALT_MASK)); menuItemHelp.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, ActionEvent.ALT_MASK)); menuBar.add(menuFile); menuBar.add(menuHelp); menuFile.add(menuItemFileOpen); menuHelp.add(menuItemHelp); mainFrame.setJMenuBar(menuBar); /////////////////////////////////////////////////////////////////// // Event Handler Setting /////////////////////////////////////////////////////////////////// menuItemFileOpen.addActionListener(new SharedActionHandler()); menuItemHelp.addActionListener(new SharedActionHandler()); buttonActivate.addActionListener(new SharedActionHandler()); buttonAnalysis.addActionListener(new SharedActionHandler()); buttonReset.addActionListener(new SharedActionHandler()); radioMultiThread.addActionListener(new SharedActionHandler()); radioSingleThread.addActionListener(new SharedActionHandler()); listPluginMajor2.addMouseListener(new PluginListMouseListener(listPluginMajor2, listModelMajor2)); listPluginMajor3.addMouseListener(new PluginListMouseListener(listPluginMajor3, listModelMajor3)); listPluginSupplement1 .addMouseListener(new PluginListMouseListener(listPluginSupplement1, listModelSupplement1)); listPluginSupplement2 .addMouseListener(new PluginListMouseListener(listPluginSupplement2, listModelSupplement2)); listPluginSupplement3 .addMouseListener(new PluginListMouseListener(listPluginSupplement3, listModelSupplement3)); listPluginMajor2.setTransferHandler(new PluginTransferHandler(PluginInfo.PHASE2, PluginInfo.MAJOR)); listPluginMajor3.setTransferHandler(new PluginTransferHandler(PluginInfo.PHASE3, PluginInfo.MAJOR)); listPluginSupplement1 .setTransferHandler(new PluginTransferHandler(PluginInfo.PHASE1, PluginInfo.SUPPLEMENT)); listPluginSupplement2 .setTransferHandler(new PluginTransferHandler(PluginInfo.PHASE2, PluginInfo.SUPPLEMENT)); listPluginSupplement3 .setTransferHandler(new PluginTransferHandler(PluginInfo.PHASE3, PluginInfo.SUPPLEMENT)); listPluginSupplement1.setDropMode(DropMode.ON_OR_INSERT); listPluginSupplement2.setDropMode(DropMode.ON_OR_INSERT); listPluginSupplement3.setDropMode(DropMode.ON_OR_INSERT); listPluginMajor2.setDropMode(DropMode.ON_OR_INSERT); listPluginMajor3.setDropMode(DropMode.ON_OR_INSERT); listPluginMajor2.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listPluginMajor3.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listPluginSupplement1.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listPluginSupplement2.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listPluginSupplement3.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listPluginMajor2.setDragEnabled(true); listPluginMajor3.setDragEnabled(true); listPluginSupplement1.setDragEnabled(true); listPluginSupplement2.setDragEnabled(true); listPluginSupplement3.setDragEnabled(true); tree.setDragEnabled(true); tempPlugin = new PluginInfo("", 0, 0); workflow = new Workflow(); // Show the main frame on the screen mainFrame.setVisible(true); for (int i = 0; i < tree.getRowCount(); i++) { tree.expandRow(i); } splitPaneTop.setDividerLocation(0.3); splitPaneBottom.setDividerLocation(0.5); }
From source file:org.jdal.swing.PageableTable.java
/** * Create the right menu bar/* www. j a v a 2 s. c om*/ */ private void createMenu() { rightMenuBar = new JMenuBar(); rightMenuBar.setLayout(new BoxLayout(rightMenuBar, BoxLayout.PAGE_AXIS)); rightMenuBar.setMargin(new Insets(0, 0, 0, 0)); // Add Visibility menu JMenu menu = new JMenu(); menu.setMargin(new Insets(0, 0, 0, 0)); menu.setIcon(visibilityMenuIcon); menu.setMaximumSize(new Dimension(50, 50)); visibilityBox = new VisibilityBox(columnDescriptors); menu.add(visibilityBox); menu.getPopupMenu().addPopupMenuListener(new VisibilityPopupListener()); JMenuItem okMenuItem = new JMenuItem(new OkVisibilityAction()); JMenuItem cancelMenuItem = new JMenuItem(new CancelVisibilityAction()); menu.addSeparator(); menu.add(okMenuItem); menu.add(cancelMenuItem); rightMenuBar.add(menu); JMenu prefsMenu = new JMenu(); prefsMenu.setMargin(new Insets(0, 0, 0, 0)); prefsMenu.setIcon(userMenuIcon); prefsMenu.setMaximumSize(new Dimension(50, 50)); prefsMenu.add(new JMenuItem(new LoadPreferencesAction(this, messageSource .getMessage("PageableTable.loadPreferences", null, "Load Preferences", Locale.getDefault())))); prefsMenu.add(new JMenuItem(new SavePreferencesAction(this, messageSource .getMessage("PageableTable.savePreferences", null, "Save Preferences", Locale.getDefault())))); rightMenuBar.add(prefsMenu); rightMenuBar.add(Box.createVerticalGlue()); // Add menu bar to right add(rightMenuBar, BorderLayout.EAST); }
From source file:com.mightypocket.ashot.Mediator.java
private JMenuBar createMenuBar() { BindingGroup menuBinding = new BindingGroup(); ResourceMap resourceMap = application.getContext().getResourceMap(Mediator.class); ApplicationActionMap actionMap = getActionMap(); JMenuBar bar = new JMenuBar(); // Menu File/*from w w w . j a va 2 s . c o m*/ JMenu menuFile = new JMenu(resourceMap.getString("menu.file")); menuFileDevices = new JMenu(resourceMap.getString("menu.file.devices.text")); menuFileDevices.setIcon(resourceMap.getIcon("menu.file.devices.icon")); menuFile.add(menuFileDevices); menuBinding.addBinding(bindRead(this, PROP_DEVICES, menuFileDevices, "enabled")); menuFile.addSeparator(); menuFile.add(new JMenuItem(actionMap.get(ACTION_SAVE_SCREENSHOT))); menuFile.add(new JCheckBoxMenuItem(actionMap.get(ACTION_RECORDING))); menuFile.add(new JMenuItem(actionMap.get(ACTION_OPEN_DESTINATION_FOLDER))); menuFile.addSeparator(); menuFile.add(new JMenuItem(actionMap.get(ACTION_CHANGE_DEFAULT_FOLDER))); menuFile.add(new JMenuItem(actionMap.get(ACTION_CHANGE_SDK_FOLDER))); menuFile.addSeparator(); menuFile.add(new JMenuItem(actionMap.get("quit"))); // Menu Edit JMenu menuEdit = new JMenu(resourceMap.getString("menu.edit")); menuEdit.add(new JMenuItem(actionMap.get(ACTION_COPY_TO_CLIPBOARD))); // Menu View JMenu menuView = new JMenu(resourceMap.getString("menu.view")); menuView.add(new JCheckBoxMenuItem(actionMap.get(ACTION_SHOW_TOOLBAR_LABELS))); menuView.addSeparator(); menuView.add(new JCheckBoxMenuItem(actionMap.get(ACTION_LANDSCAPE))); menuView.add(new JCheckBoxMenuItem(actionMap.get(ACTION_LANDSCAPE_CW))); menuView.addSeparator(); menuView.add(new JMenuItem(actionMap.get(ACTION_ZOOM_IN))); menuView.add(new JMenuItem(actionMap.get(ACTION_ZOOM_OUT))); menuView.add(new JMenuItem(actionMap.get(ACTION_SIZE_ORIGINAL))); menuView.add(new JMenuItem(actionMap.get(ACTION_SIZE_SMALL))); menuView.add(new JMenuItem(actionMap.get(ACTION_SIZE_LARGE))); menuView.add(new JCheckBoxMenuItem(actionMap.get(ACTION_SIZE_FIT))); menuView.addSeparator(); menuView.add(new JMenuItem(actionMap.get(ACTION_FULL_SCREEN))); // Menu Tools JMenu toolsView = new JMenu(resourceMap.getString("menu.tools")); toolsView.add(new JMenuItem(actionMap.get(ACTION_INSTALL))); toolsView.addSeparator(); toolsView.add(new JMenuItem(actionMap.get(ACTION_OPTIONS))); // Menu Help JMenu menuHelp = new JMenu(resourceMap.getString("menu.help")); menuHelp.add(new JMenuItem(actionMap.get(ACTION_CHECK_UPDATES))); menuHelp.add(new JMenuItem(actionMap.get(ACTION_ABOUT))); bar.add(menuFile); bar.add(menuEdit); bar.add(menuView); bar.add(toolsView); bar.add(menuHelp); menuBinding.bind(); return bar; }