List of usage examples for javax.swing JMenuBar add
public JMenu add(JMenu c)
From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java
private JMenuBar createMenuBar() { final JMenuBar menuBar = new JMenuBar(); JMenuItem mItem = null;//from ww w . j a v a2 s . com String urlString; URL url; //============================================================================================ // File Menu //============================================================================================ JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('f'); menuBar.add(fileMenu); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-new.png"; url = this.getClass().getResource(urlString); ImageIcon iconNew = new ImageIcon(url, "New"); mItem = new JMenuItem(new NewTextFileAction("New", iconNew)); fileMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-open.png"; url = this.getClass().getResource(urlString); ImageIcon iconOpen = new ImageIcon(url, "Open"); mItem = new JMenuItem(new OpenFileAction("Open...", iconOpen, new Integer(KeyEvent.VK_A))); fileMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-save.png"; url = this.getClass().getResource(urlString); ImageIcon iconSave = new ImageIcon(url, "Save"); mItem = new JMenuItem(new SaveAction("Save", iconSave, new Integer(KeyEvent.VK_S))); fileMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-save-as.png"; url = this.getClass().getResource(urlString); ImageIcon iconSaveAs = new ImageIcon(url, "Save As"); mItem = new JMenuItem(new SaveAsAction("Save As...", iconSaveAs)); fileMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/status/folder-visiting.png"; url = this.getClass().getResource(urlString); ImageIcon iconClose = new ImageIcon(url, "Close All Tabs"); mItem = new JMenuItem(new CloseAllTabsAction("Close All Tabs...", iconClose, new Integer(KeyEvent.VK_C))); fileMenu.add(mItem); fileMenu.addSeparator(); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-print.png"; url = this.getClass().getResource(urlString); ImageIcon iconPrint = new ImageIcon(url, "Print"); mItem = new JMenuItem(new PrintAction("Print...", iconPrint)); fileMenu.add(mItem); fileMenu.addSeparator(); // exit menu item urlString = "/org/tango-project/tango-icon-theme/16x16/actions/system-log-out.png"; url = this.getClass().getResource(urlString); ImageIcon iconExit = new ImageIcon(url, "Exit"); mItem = new JMenuItem(new ExitAction("Exit", iconExit)); fileMenu.add(mItem); //============================================================================================ // Edit Menu //============================================================================================ JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic(KeyEvent.VK_E); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-cut.png"; url = this.getClass().getResource(urlString); ImageIcon iconCut = new ImageIcon(url, "Cut"); mItem = new JMenuItem(new DefaultEditorKit.CutAction()); mItem.setText("Cut"); mItem.setIcon(iconCut); mItem.setMnemonic(KeyEvent.VK_X); editMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-copy.png"; url = this.getClass().getResource(urlString); ImageIcon iconCopy = new ImageIcon(url, "Copy"); mItem = new JMenuItem(new DefaultEditorKit.CopyAction()); mItem.setText("Copy"); mItem.setIcon(iconCopy); mItem.setMnemonic(KeyEvent.VK_C); editMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-paste.png"; url = this.getClass().getResource(urlString); ImageIcon iconPaste = new ImageIcon(url, "Paste"); mItem = new JMenuItem(new DefaultEditorKit.PasteAction()); mItem.setText("Paste"); mItem.setIcon(iconPaste); mItem.setMnemonic(KeyEvent.VK_V); editMenu.add(mItem); editMenu.addSeparator(); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-undo.png"; url = this.getClass().getResource(urlString); ImageIcon iconUndo = new ImageIcon(url, "Undo"); mItem = new JMenuItem(new UndoAction("Undo", iconUndo, new Integer(KeyEvent.VK_Z))); editMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-redo.png"; url = this.getClass().getResource(urlString); ImageIcon iconRedo = new ImageIcon(url, "Redo"); mItem = new JMenuItem(new RedoAction("Redo", iconRedo, new Integer(KeyEvent.VK_Y))); editMenu.add(mItem); editMenu.addSeparator(); urlString = "/org/tango-project/tango-icon-theme/16x16/categories/preferences-system.png"; url = this.getClass().getResource(urlString); ImageIcon iconView = new ImageIcon(url, "Preferences"); mItem = new JMenuItem("Preferences"); mItem.setIcon(iconView); mItem.setToolTipText("Edit jMetrik preferences"); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JmetrikPreferencesManager prefs = new JmetrikPreferencesManager(); prefs.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener()); prefs.addPropertyChangeListener(statusBar.getStatusListener()); JmetrikPreferencesDialog propDialog = new JmetrikPreferencesDialog(Jmetrik.this, prefs); // propDialog.loadPreferences(); propDialog.setVisible(true); } }); editMenu.setMnemonic('e'); editMenu.add(mItem); menuBar.add(editMenu); //============================================================================================ // Log Menu //============================================================================================ JMenu logMenu = new JMenu("Log"); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-properties.png"; url = this.getClass().getResource(urlString); ImageIcon iconLog = new ImageIcon(url, "View Log"); mItem = new JMenuItem(new ViewLogAction("View Log", iconLog)); logMenu.setMnemonic('l'); logMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/mimetypes/text-x-generic.png"; url = this.getClass().getResource(urlString); ImageIcon iconCommand = new ImageIcon(url, "Script Log"); mItem = new JMenuItem(new ViewScriptLogAction("Script Log", iconCommand)); logMenu.setMnemonic('c'); logMenu.add(mItem); menuBar.add(logMenu); //============================================================================================ // Manage Menu //============================================================================================ JMenu manageMenu = new JMenu("Manage"); manageMenu.setMnemonic('m'); mItem = new JMenuItem("New Database...");//create db mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NewDatabaseDialog newDatabaseDialog = new NewDatabaseDialog(Jmetrik.this); newDatabaseDialog.setVisible(true); if (newDatabaseDialog.canRun()) { if (workspace == null) { // workspace = new Workspace(workspaceTree, tabbedPane, dataTable, variableTable); workspace = new Workspace(workspaceList, tabbedPane, dataTable, variableTable); workspace.addPropertyChangeListener(statusBar.getStatusListener()); workspace.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener()); } workspace.runProcess(newDatabaseDialog.getCommand()); // workspace.createDatabase(newDatabaseDialog.getCommand()); } } }); manageMenu.add(mItem); mItem = new JMenuItem("Open Database..."); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OpenDatabaseDialog openDbDialog = new OpenDatabaseDialog(Jmetrik.this, "Open"); JList l = openDbDialog.getDatabaseList(); workspace.setDatabaseListModel(l); openDbDialog.setVisible(true); if (openDbDialog.canRun()) { openWorkspace(openDbDialog.getDatabaseName()); } } }); manageMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png"; url = this.getClass().getResource(urlString); ImageIcon iconDelete = new ImageIcon(url, "Delete"); mItem = new JMenuItem("Delete Database..."); mItem.setIcon(iconDelete); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OpenDatabaseDialog selectDialog = new OpenDatabaseDialog(Jmetrik.this, "Delete"); JList l = selectDialog.getDatabaseList(); workspace.setDatabaseListModel(l); selectDialog.setVisible(true); if (selectDialog.canRun()) { int answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete " + selectDialog.getDatabaseName() + " and all of its contents? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); if (answer == JOptionPane.YES_OPTION) { DatabaseCommand command = new DatabaseCommand(); DatabaseName dbName = new DatabaseName(selectDialog.getDatabaseName()); command.getFreeOption("name").add(dbName.getName()); command.getSelectOneOption("action").setSelected("delete-db"); DatabaseName currentDb = workspace.getDatabaseName(); if (currentDb.getName().equals(dbName.getName())) { JOptionPane.showMessageDialog(Jmetrik.this, "You cannot delete the current database.\n" + "Close the database before attempting to delete it.", "Database Delete Error", JOptionPane.WARNING_MESSAGE); } else { workspace.runProcess(command); } } } } }); manageMenu.add(mItem); manageMenu.addSeparator(); urlString = "/org/tango-project/tango-icon-theme/16x16/apps/accessories-text-editor.png"; url = this.getClass().getResource(urlString); ImageIcon iconDesc = new ImageIcon(url, "Descriptions"); mItem = new JMenuItem("Table Descriptions..."); mItem.setIcon(iconDesc); mItem.addActionListener(new TableDescriptionActionListener()); manageMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/list-add.png"; url = this.getClass().getResource(urlString); ImageIcon iconImport = new ImageIcon(url, "Import"); mItem = new JMenuItem("Import Data..."); mItem.setIcon(iconImport); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (workspace.databaseOpened()) { ImportDialog importDialog = new ImportDialog(Jmetrik.this, workspace.getDatabaseName(), importExportPath); importDialog.setVisible(true); if (importDialog.canRun()) { importExportPath = importDialog.getCurrentDirectory(); workspace.runProcess(importDialog.getCommand()); } } else { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before importing data.", "No Open Database", JOptionPane.ERROR_MESSAGE); } } }); manageMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/format-indent-less.png"; url = this.getClass().getResource(urlString); ImageIcon iconExport = new ImageIcon(url, "Export"); mItem = new JMenuItem("Export Data..."); mItem.setIcon(iconExport); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DataTableName tableName = (DataTableName) workspaceList.getSelectedValue(); if (!workspace.databaseOpened()) { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before exporting data.", "No Open Database", JOptionPane.ERROR_MESSAGE); } else if (tableName == null) { JOptionPane.showMessageDialog(Jmetrik.this, "You must select a table in the workspace list. \n " + "Select a table to continue the export.", "No Table Selected", JOptionPane.ERROR_MESSAGE); } else { ExportDataDialog exportDialog = new ExportDataDialog(Jmetrik.this, workspace.getDatabaseName(), tableName, importExportPath); if (exportDialog.canRun()) { importExportPath = exportDialog.getCurrentDirectory(); workspace.runProcess(exportDialog.getCommand()); } } } }); manageMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png"; url = this.getClass().getResource(urlString); ImageIcon iconDeleteTable = new ImageIcon(url, "Delete"); mItem = new JMenuItem("Delete Table..."); mItem.setIcon(iconDeleteTable); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (workspace.databaseOpened()) { DeleteTableDialog deleteDialog = new DeleteTableDialog(Jmetrik.this, workspace.getDatabaseName(), (SortedListModel<DataTableName>) workspaceList.getModel()); deleteDialog.setVisible(true); if (deleteDialog.canRun()) { int nSelected = deleteDialog.getNumberOfSelectedTables(); int answer = JOptionPane.NO_OPTION; if (nSelected > 1) { answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete these " + nSelected + " tables? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); } else { ArrayList<DataTableName> dList = deleteDialog.getSelectedTables(); answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete the table " + dList.get(0).getTableName() + "? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); } if (answer == JOptionPane.YES_OPTION) { workspace.runProcess(deleteDialog.getCommand()); } } } else { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before deleting a table.", "No Open Database", JOptionPane.ERROR_MESSAGE); } } }); manageMenu.add(mItem); manageMenu.addSeparator(); SubsetCasesProcess subsetCasesProcess = new SubsetCasesProcess(); subsetCasesProcess.addMenuItem(Jmetrik.this, manageMenu, dialogs, workspace, workspaceList); SubsetVariablesProcess subsetVariablesProcess = new SubsetVariablesProcess(); subsetVariablesProcess.addMenuItem(Jmetrik.this, manageMenu, dialogs, workspace, workspaceList); urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png"; url = this.getClass().getResource(urlString); ImageIcon iconDeleteVariables = new ImageIcon(url, "Delete Variables"); mItem = new JMenuItem("Delete Variables..."); mItem.setIcon(iconDeleteVariables); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DataTableName tableName = (DataTableName) workspaceList.getSelectedValue(); if (!workspace.databaseOpened()) { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before subsetting data.", "No Open Database", JOptionPane.ERROR_MESSAGE); } else if (tableName == null) { JOptionPane.showMessageDialog(Jmetrik.this, "You must select a table in the workspace list. \n " + "Select a table to continue.", "No Table Selected", JOptionPane.ERROR_MESSAGE); } else if (workspace.tableOpen()) { DeleteVariableDialog deleteVariableDialog = new DeleteVariableDialog(Jmetrik.this, workspace.getDatabaseName(), workspace.getCurrentDataTable(), workspace.getVariables()); deleteVariableDialog.setVisible(true); if (deleteVariableDialog.canRun()) { int nSelected = deleteVariableDialog.getNumberOfSelectedVariables(); int answer = JOptionPane.NO_OPTION; if (nSelected > 1) { answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete these " + nSelected + " variables? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Variables", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); } else { VariableAttributes v = deleteVariableDialog.getSelectedVariable(); answer = JOptionPane.showConfirmDialog(Jmetrik.this, "Do you want to delete the variable " + v.getName().toString() + "? \n" + "All data will be permanently deleted. You cannot undo this action.", "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION); } if (answer == JOptionPane.YES_OPTION) { workspace.runProcess(deleteVariableDialog.getCommand()); } } } } }); manageMenu.add(mItem); menuBar.add(manageMenu); //============================================================================================ // Transform Menu //============================================================================================ JMenu transformMenu = new JMenu("Transform"); transformMenu.setMnemonic('t'); BasicScoringProcess basicScoringProcess = new BasicScoringProcess(); basicScoringProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); ScoringProcess scoringProcess = new ScoringProcess(); scoringProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); transformMenu.addSeparator(); RankingProcess rankingProcess = new RankingProcess(); rankingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); TestScalingProcess testScalingProcess = new TestScalingProcess(); testScalingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); LinearTransformationProcess linearTransformationProcess = new LinearTransformationProcess(); linearTransformationProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); transformMenu.addSeparator(); IrtLinkingProcess irtLinkingProcess = new IrtLinkingProcess(); irtLinkingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); IrtEquatingProcess irtEquatingProcess = new IrtEquatingProcess(); irtEquatingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList); menuBar.add(transformMenu); //============================================================================================ // Analyze Menu //============================================================================================ JMenu analyzeMenu = new JMenu("Analyze"); analyzeMenu.setMnemonic('a'); FrequencyProcess frequencyProcess = new FrequencyProcess(); frequencyProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); DescriptiveProcess descriptiveProcess = new DescriptiveProcess(); descriptiveProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); CorrelationProcess correlationProcess = new CorrelationProcess(); correlationProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); analyzeMenu.addSeparator(); ItemAnalysisProcess itemAnalysisProcess = new ItemAnalysisProcess(); itemAnalysisProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); CmhProcess cmhProcess = new CmhProcess(); cmhProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); analyzeMenu.addSeparator(); RaschAnalysisProcess raschAnalysisProcess = new RaschAnalysisProcess(); raschAnalysisProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); IrtItemCalibrationProcess irtItemCalibrationProcess = new IrtItemCalibrationProcess(); irtItemCalibrationProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); IrtPersonScoringProcess irtPersonScoringProcess = new IrtPersonScoringProcess(); irtPersonScoringProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList); menuBar.add(analyzeMenu); //============================================================================================ // Graph Menu //============================================================================================ JMenu graphMenu = new JMenu("Graph"); graphMenu.setMnemonic('g'); BarChartProcess barchartProcess = new BarChartProcess(); barchartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); PieChartProcess piechartProcess = new PieChartProcess(); piechartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); graphMenu.addSeparator(); HistogramProcess histogramProcess = new HistogramProcess(); histogramProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); DensityProcess densityProcess = new DensityProcess(); densityProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); LineChartProcess lineChartProcess = new LineChartProcess(); lineChartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); ScatterplotProcess scatterplotProcess = new ScatterplotProcess(); scatterplotProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); graphMenu.addSeparator(); NonparametricCurveProcess nonparametricCurveProcess = new NonparametricCurveProcess(); nonparametricCurveProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); mItem = new JMenuItem("Irt Plot..."); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { DataTableName tableName = (DataTableName) workspaceList.getSelectedValue(); if (tableName == null) { JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database and select a table. \n " + "Select a table to continue scoring.", "No Table Selected", JOptionPane.ERROR_MESSAGE); } else { if (irtPlotDialog == null && workspace.tableOpen()) { //Note that starting this dialog is different because variables //names must be obtained from the rows of a table. DatabaseAccessObject dao = workspace.getDatabaseFactory().getDatabaseAccessObject(); try { ArrayList<VariableAttributes> tempVar = dao.getVariableAttributesFromColumn( workspace.getConnection(), workspace.getCurrentDataTable(), new VariableName("name")); irtPlotDialog = new IrtPlotDialog(Jmetrik.this, workspace.getDatabaseName(), tableName, tempVar, (SortedListModel<DataTableName>) workspaceList.getModel()); } catch (SQLException ex) { logger.fatal(ex.getMessage(), ex); firePropertyChange("error", "", "Error - Check log for details."); } } if (irtPlotDialog != null) irtPlotDialog.setVisible(true); } if (irtPlotDialog != null && irtPlotDialog.canRun()) { workspace.runProcess(irtPlotDialog.getCommand()); } } }); graphMenu.add(mItem); ItemMapProcess itemMapProcess = new ItemMapProcess(); itemMapProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList); menuBar.add(graphMenu); //============================================================================================ // Command Menu //============================================================================================ JMenu commandMenu = new JMenu("Commands"); commandMenu.setMnemonic('c'); mItem = new JMenuItem("Run command"); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JScrollPane pain = (JScrollPane) tabbedPane.getSelectedComponent(); JViewport vp = pain.getViewport(); Component c = vp.getComponent(0); if (c instanceof JmetrikTextFile) { JmetrikTab tempTab = (JmetrikTab) tabbedPane.getTabComponentAt(tabbedPane.getSelectedIndex()); JmetrikTextFile textFile = (JmetrikTextFile) c; workspace.runFromSyntax(textFile.getText()); } } }); commandMenu.add(mItem); mItem = new JMenuItem("Stop command"); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //add something } }); mItem.setEnabled(false); commandMenu.add(mItem); mItem = new JMenuItem("Command Reference..."); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //add something } }); mItem.setEnabled(false); commandMenu.add(mItem); menuBar.add(commandMenu); //============================================================================================ // Help Menu //============================================================================================ JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic('h'); mItem = new JMenuItem("Quick Start Guide"); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Desktop deskTop = Desktop.getDesktop(); try { URI uri = new URI("http://www.itemanalysis.com/quick-start-guide.php"); deskTop.browse(uri); } catch (URISyntaxException ex) { logger.fatal(ex.getMessage(), ex); firePropertyChange("error", "", "Error - Check log for details."); } catch (IOException ex) { logger.fatal(ex.getMessage(), ex); firePropertyChange("error", "", "Error - Check log for details."); } } }); helpMenu.add(mItem); urlString = "/org/tango-project/tango-icon-theme/16x16/apps/help-browser.png"; url = this.getClass().getResource(urlString); ImageIcon iconAbout = new ImageIcon(url, "About"); mItem = new JMenuItem("About"); mItem.setIcon(iconAbout); mItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JmetrikAboutDialog aboutDialog = new JmetrikAboutDialog(Jmetrik.this, APP_NAME, VERSION, AUTHOR, RELEASE_DATE, COPYRIGHT_YEAR, BETA_VERSION); aboutDialog.setVisible(true); } }); helpMenu.add(mItem); menuBar.add(helpMenu); return menuBar; }
From source file:org.angnysa.yaba.swing.BudgetFrame.java
private void buildMenubar() { JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu(Messages.getString("menu.file.label")); //$NON-NLS-1$ JMenuItem item;//from ww w .j a v a 2s . co m // new item = new JMenuItem(Messages.getString("menu.file.new")); //$NON-NLS-1$ item.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingMain.newEditor(null); } }); fileMenu.add(item); // open item = new JMenuItem(Messages.getString("menu.file.open")); //$NON-NLS-1$ item.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingMain.open(id); } }); fileMenu.add(item); // save item = new JMenuItem(Messages.getString("menu.file.save")); //$NON-NLS-1$ item.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingMain.save(id); } }); fileMenu.add(item); // save as item = new JMenuItem(Messages.getString("menu.file.save-as")); //$NON-NLS-1$ item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingMain.saveas(id); } }); fileMenu.add(item); // close item = new JMenuItem(Messages.getString("menu.file.close")); //$NON-NLS-1$ item.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingMain.close(id); } }); fileMenu.add(item); menuBar.add(fileMenu); setJMenuBar(menuBar); }
From source file:com.declarativa.interprolog.gui.ListenerWindow.java
void constructMenu() { JMenuBar mb; mb = new JMenuBar(); setJMenuBar(mb);// w w w . j av a2 s . c o m final CallsFromArgBuilder2XSB calls2XSB = new CallsFromArgBuilder2XSB(); /** * **************************************************************** * ***************ENTRY POINT FOR CALLING THE ARGXSB ANALYSIS ***** * **************************************************************** * * Carga un archivo con las reglas para crear los argumentos */ loadRules = new JMenu(""); loadRules.setMnemonic('A'); mb.add(loadRules); addItemToMenu(loadRules, "Select a Program", 'S', new ActionListener() { public void actionPerformed(ActionEvent e) { //jLayeredPane1.setVisible(true); //WORKFLOW: //1. Load File //2. clause partition //3. graph creation //4. extract subgraphs //5. create a file for each subgraph //6. consult via XSB, each sub-file (sub-graph) /** * deleteing previous files */ String calls_for_table = "";//maybe temporal String returns_for_call = ""; //the file is loaded GraphAnalysis(); try { ReDrawGraph(); } catch (IOException ex) { Exceptions.printStackTrace(ex); //System.out.println("EXCEPCION EN REDRAW CALL"); } /* //remueve el .P del archivo String nameFile = calls2XSB.File2Consult(getNameOfFileToLoad()); System.out.println("=============_" + nameFile); //StringTokenizer st2 = new StringTokenizer(getNameOfFileToLoad(), "."); //String nameFile = st2.nextElement().toString(); sendCallToProlog("consult(" + nameFile + ")."); //retorna los valores de True False de cada atomo //estos debeian guardarse en la base de datos para luego // obtener los argumentos calls_for_table = calls2XSB.FindCallsForTable(engine); returns_for_call = calls2XSB.FindReturnsForCall(engine); */ java.util.List<String> filenames = new ArrayList(); filenames = printArguments(); for (Iterator<String> it = filenames.iterator(); it.hasNext();) { String string = it.next(); //System.out.println("\t\t --------------> name:" + string); //System.out.println("\t \t *************************************************"); /* try { System.out.println(new File(".").getCanonicalPath()); System.out.println("DIR:" + new File("../examples/").getCanonicalPath()); System.out.println("DIR:" + new File("../examples/"+string).getCanonicalPath()); } catch (java.io.IOException ex) { System.out.println("ex." + ex.getLocalizedMessage()); } */ consultFile("../examples/" + string); String nameFile3 = calls2XSB.File2Consult(string); //sendCallToProlog("consult(" + nameFile3 + ")."); sendCallToProlog(nameFile3); //calls_for_table = calls2XSB.FindCallsForTable(engine); //returns_for_call = calls2XSB.FindReturnsForCall(engine, string); calls2XSB.WFSEvaluation(engine, string); //System.out.println("\t \t *************************************************"); } ArgumentWriter(); drawArguments(); /* String atomGoal ="p(X)"; String atomGoal2 = "findall(Y,p(Y), L)"; String atomGoal3 ="findall(Call,get_calls_for_table(p/1,Call),List)"; String atomGoal4 ="findall(Answer,get_returns_for_call(p(_),Answer),List2)"; try { String G = "(X=a;X=b)"; String T = "X"; String GG = "findall(TM, ("+atomGoal3+",buildTermModel(List,TM)), L), ipObjectSpec('ArrayOfObject',L,LM)"; String GG2 = "findall(TM, ("+atomGoal4+",buildTermModel(List2,TM)), L), ipObjectSpec('ArrayOfObject',L,LM)"; Object[] bindings0 = engine.deterministicGoal(atomGoal,null); Object[] bindings = engine.deterministicGoal(atomGoal3,null); Object[] get_calls_for_table = (Object[])engine.deterministicGoal(GG,"[LM]")[0]; Object[] get_returns_for_call = (Object[])engine.deterministicGoal(GG2,"[LM]")[0]; //System.out.println("Number of solutions:"+get_calls_for_table.length); for(int I=0;I<get_calls_for_table.length;I++) System.out.println("Solution "+I+":"+get_calls_for_table[I]); //System.out.println("Number of bindings:"+get_returns_for_call.length); for(int I=0;I<get_returns_for_call.length;I++) System.out.println("Solution2 "+I+":"+get_returns_for_call[I]); } catch (IPAbortedException exc) { exc.printStackTrace(); System.out.println("Exception!: "+exc.getLocalizedMessage()); } catch (IPInterruptedException ex) { ex.printStackTrace(); System.out.println("Exception!: "+ex.getLocalizedMessage()); } */ } }); fileMenu = new JMenu("File"); fileMenu.setMnemonic('F'); // mb.add(fileMenu); addItemToMenu(fileMenu, "Consult...", 'C', new ActionListener() { public void actionPerformed(ActionEvent e) { reconsultFile(); } }); if (engine.getImplementationPeer() instanceof XSBPeer) { addItemToMenu(fileMenu, "Load dynamically...", 'L', new ActionListener() { public void actionPerformed(ActionEvent e) { load_dynFile(); } }); } fileMenu.addSeparator(); JMenu toolMenu = new JMenu("Tools"); toolMenu.setMnemonic('T'); // mb.add(toolMenu); final JCheckBoxMenuItem debugging = new JCheckBoxMenuItem("Engine debugging"); toolMenu.add(debugging); debugging.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { engine.setDebug(debugging.isSelected()); } }); addItemToMenu(toolMenu, "See Object Specifications", 'S', new ActionListener() { public void actionPerformed(ActionEvent e) { engine.command("showObjectVariables"); } }); addItemToMenu(toolMenu, "Interrupt Prolog", 'I', new ActionListener() { public void actionPerformed(ActionEvent e) { engine.interrupt(); } }); /* addItemToMenu(toolMenu,"Serialize JFrame",new ActionListener(){ public void actionPerformed(ActionEvent e){ Object [] toSerialize = {new JFrame("My window")}; engine.setDebug(true); System.out.println(engine.deterministicGoal("true","[Object]",toSerialize)); } });*/ historyMenu = new JMenu("History", true); historyMenu.setMnemonic('H'); // mb.add(historyMenu); historyMenu.addSeparator(); // to avoid Swing bug handling key events }
From source file:jmap2gml.ScriptGui.java
/** * Formats the window, initializes the JMap2Script object, and sets up all * the necessary events.// ww w . ja v a2 s. c om */ public ScriptGui() { setTitle("jmap to gml script converter"); setDefaultCloseOperation(EXIT_ON_CLOSE); getContentPane().setLayout(new GridBagLayout()); this.addWindowListener(new WindowListener() { @Override public void windowOpened(WindowEvent we) { } @Override public void windowClosing(WindowEvent we) { saveConfig(); } @Override public void windowClosed(WindowEvent we) { } @Override public void windowIconified(WindowEvent we) { } @Override public void windowDeiconified(WindowEvent we) { } @Override public void windowActivated(WindowEvent we) { } @Override public void windowDeactivated(WindowEvent we) { } }); GridBagConstraints c = new GridBagConstraints(); setResizable(true); setIconImage((new ImageIcon("spikeup.png")).getImage()); jta = new JTextArea(38, 30); loadConfig(); JScrollPane jsp = new JScrollPane(jta); jsp.setRowHeaderView(new TextLineNumber(jta)); jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); jsp.setSize(jsp.getWidth(), 608); // menu bar JMenuBar menubar = new JMenuBar(); // file menu JMenu file = new JMenu("File"); // load button JMenuItem load = new JMenuItem("Load jmap"); load.addActionListener(ae -> { JFileChooser fileChooser = new JFileChooser(prevDirectory); fileChooser.setFileFilter(new FileNameExtensionFilter("jmap file", "jmap", "jmap")); int returnValue = fileChooser.showOpenDialog(null); if (returnValue == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); prevDirectory = selectedFile.getAbsolutePath(); jm2s = new ScriptFromJmap(selectedFile.getPath(), false); jta.setText(""); jta.append(jm2s.toString()); jta.setCaretPosition(0); writeFile.setEnabled(true); drawPanel.setItems(jta.getText().split("\n")); } }); // add load to file menu file.add(load); // button to save script to file writeFile = new JMenuItem("Write file"); writeFile.addActionListener(ae -> { if (jm2s != null) { PrintWriter out; try { File f = new File( jm2s.getFileName().substring(0, jm2s.getFileName().lastIndexOf(".jmap")) + ".gml"); out = new PrintWriter(f); out.append(jm2s.toString()); out.close(); } catch (FileNotFoundException ex) { Logger.getLogger(ScriptGui.class.getName()).log(Level.SEVERE, null, ex); } } }); writeFile.setEnabled(false); JMenuItem gmx = new JMenuItem("Export as gmx"); gmx.addActionListener(ae -> { String fn = String.format("%s.room.gmx", prevDirectory); JFileChooser fc = new JFileChooser(prevDirectory); fc.setSelectedFile(new File(fn)); fc.setFileFilter(new FileNameExtensionFilter("Game Maker XML", "gmx", "gmx")); fc.showDialog(null, "Save"); File f = fc.getSelectedFile(); if (f != null) { try { GMX.itemsToGMX(drawPanel.items, new FileOutputStream(f)); } catch (FileNotFoundException ex) { Logger.getLogger(ScriptGui.class.getName()).log(Level.SEVERE, null, ex); } } }); // add to file menu file.add(writeFile); file.add(gmx); // add file menu to the menubar menubar.add(file); // Edit menu // display menu JMenu display = new JMenu("Display"); JMenuItem update = new JMenuItem("Update"); update.addActionListener(ae -> { drawPanel.setItems(jta.getText().split("\n")); }); display.add(update); JMenuItem gridToggle = new JMenuItem("Toggle Grid"); gridToggle.addActionListener(ae -> { drawPanel.toggleGrid(); }); display.add(gridToggle); JMenuItem gridOptions = new JMenuItem("Modify Grid"); gridOptions.addActionListener(ae -> { drawPanel.modifyGrid(); }); display.add(gridOptions); menubar.add(display); // sets the menubar setJMenuBar(menubar); // add the text area to the window c.gridx = 0; c.gridy = 0; add(jsp, c); // initialize the preview panel drawPanel = new Preview(this); JScrollPane scrollPane = new JScrollPane(drawPanel); // add preview panel to the window c.gridx = 1; c.gridwidth = 2; add(scrollPane, c); pack(); setMinimumSize(this.getSize()); setLocationRelativeTo(null); setVisible(true); drawPanel.setItems(jta.getText().split("\n")); }
From source file:edu.ku.brc.specify.tools.l10nios.StrLocalizerAppForiOS.java
/** * @param frame/* www .j a v a 2 s.c o m*/ */ 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:org.simbrain.plot.projection.ProjectionGui.java
/** * Creates the menu bar.//w w w . ja v a 2 s . c o m */ private void createAttachMenuBar() { final JMenuBar bar = new JMenuBar(); final JMenu fileMenu = new JMenu("File"); for (Action action : actionManager.getOpenSavePlotActions()) { fileMenu.add(action); } fileMenu.addSeparator(); final JMenu exportImport = new JMenu("Export/Import..."); fileMenu.add(exportImport); exportImport.add(ProjectionPlotActions.getImportData(getWorkspaceComponent().getProjectionModel())); exportImport.addSeparator(); exportImport.add(ProjectionPlotActions.getExportDataHi(getWorkspaceComponent().getProjectionModel())); exportImport.add(ProjectionPlotActions.getExportDataLow(getWorkspaceComponent().getProjectionModel())); fileMenu.addSeparator(); fileMenu.add(new CloseAction(this.getWorkspaceComponent())); final JMenu editMenu = new JMenu("Edit"); final JMenuItem preferencesGeneral = new JMenuItem("General Preferences..."); preferencesGeneral.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { ProjectionPreferencesDialog dialog = new ProjectionPreferencesDialog( getWorkspaceComponent().getProjectionModel().getProjector()); dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); } }); editMenu.add(preferencesGeneral); final JMenuItem colorPrefs = new JMenuItem("Datapoint Coloring..."); colorPrefs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { DataPointColoringDialog dialog = new DataPointColoringDialog( getWorkspaceComponent().getProjectionModel()); dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); } }); editMenu.add(colorPrefs); final JMenuItem dims = new JMenuItem("Set dimensions..."); dims.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { String dimensions = JOptionPane.showInputDialog("Dimensions:"); if (dimensions != null) { getWorkspaceComponent().getProjectionModel().getProjector().init(Integer.parseInt(dimensions)); } } }); // editMenu.add(dims); JMenu helpMenu = new JMenu("Help"); JMenuItem helpItem = new JMenuItem(helpAction); helpMenu.add(helpItem); bar.add(fileMenu); bar.add(editMenu); bar.add(helpMenu); getParentFrame().setJMenuBar(bar); }
From source file:com.lfv.lanzius.server.LanziusServer.java
public void init() { log.info(Config.VERSION + "\n"); docVersion = 0;/* ww w. jav a 2 s .com*/ 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>(); }
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// ww w .ja v a 2 s . c om 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; }
From source file:ucar.unidata.idv.flythrough.Flythrough.java
/** * _more_//from w w w . j a v a 2 s .c o m * * @return _more_ */ public JMenuBar doMakeMenuBar() { JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = GuiUtils.makeDynamicMenu("File", this, "initFileMenu"); JMenu editMenu = GuiUtils.makeDynamicMenu("Edit", this, "initEditMenu"); JMenu viewMenu = GuiUtils.makeDynamicMenu("View", this, "initViewMenu"); menuBar.add(fileMenu); menuBar.add(editMenu); menuBar.add(viewMenu); return menuBar; }
From source file:com.qspin.qtaste.ui.MainPanel.java
protected void genMenu(final TestCaseTree tct) { final JFrame owner = this; JMenuBar menuBar = new JMenuBar(); JMenu tools = new JMenu("Tools"); tools.setMnemonic(KeyEvent.VK_T); // Tools|Config menu item JMenuItem config = new JMenuItem("Config", KeyEvent.VK_D); config.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //ATEConfigEditPanel configPanel = new ATEConfigEditPanel(null); //configPanel.setVisible(true); MainConfigFrame configFrame = new MainConfigFrame(); configFrame.launch();/*from ww w. j ava 2 s. c om*/ configFrame.addWindowListener(new WindowListener() { public void windowOpened(WindowEvent e) { } public void windowClosing(WindowEvent e) { } public void windowClosed(WindowEvent e) { // refresh the Configuration information display refreshParams(); } public void windowIconified(WindowEvent e) { } public void windowDeiconified(WindowEvent e) { } public void windowActivated(WindowEvent e) { } public void windowDeactivated(WindowEvent e) { } }); } }); tools.add(config); // Tools|delete results menu item JMenuItem deleteResults = new JMenuItem("Delete Results", KeyEvent.VK_D); final MainPanel ui = this; deleteResults.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String baseDir = TestEngineConfiguration.getInstance().getString("reporting.generated_report_path"); new File(baseDir, baseDir); // TO DO : delete really the files JOptionPane.showMessageDialog(ui, "Results have been deleted"); } }); tools.add(deleteResults); JMenu fileMenu = new JMenu("File"); JMenuItem importTestSuites = new JMenuItem("Import TestSuites"); importTestSuites.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // mTestCasePanel.importTestSuites(); } }); fileMenu.add(importTestSuites); JMenu help = new JMenu("Help"); help.setMnemonic(KeyEvent.VK_H); JMenuItem about = new JMenuItem("About", KeyEvent.VK_A); about.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new AboutDialog(owner); } }); help.add(about); JMenuItem ateUserManuel = new JMenuItem("User Manual"); ateUserManuel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { viewQTasteUserManuel(); } }); help.add(ateUserManuel); //menuBar.add(tools); // not to be used at this time!!!!!!!!! //menuBar.add(fileMenu); menuBar.add(help); setJMenuBar(menuBar); }