Example usage for javax.swing JMenuBar JMenuBar

List of usage examples for javax.swing JMenuBar JMenuBar

Introduction

In this page you can find the example usage for javax.swing JMenuBar JMenuBar.

Prototype

public JMenuBar() 

Source Link

Document

Creates a new menu bar.

Usage

From source file:edu.clemson.cs.nestbed.client.gui.ConfigManagerFrame.java

private final JMenuBar buildMenuBar() {
    JMenuBar menuBar = new JMenuBar();

    menuBar.add(buildFileMenu());/*ww w .  ja  va  2s  . c  om*/
    menuBar.add(buildProgramMenu());
    menuBar.add(buildProfilingMenu());

    return menuBar;
}

From source file:graph.jung2.MyLensDemo.java

public void init() {

    // create a simple graph for the demo
    TemporalNetworkOfWikipediaNodes net = null;
    try {/*from  w w  w.j  av  a  2s .  co m*/

        // net = new TemporalNetworkOfWikipediaNodes(null, null);
        net = new TemporalNetworkOfWikipediaNodes(r, level);
        graph = net.createSampleNetwork(); //getCC_EDIT_Graph();

    } catch (Exception ex) {
        Logger.getLogger(MyLensDemo.class.getName()).log(Level.SEVERE, null, ex);
    }

    //        if ( net == null ) {
    //            graph = TemporalNetworkOfWikipediaNodes.createSampleNetwork();
    //        }
    //        else {
    //            graph = net.getGraph();
    //        }

    graphLayout = new FRLayout<String, Number>(graph);
    ((FRLayout) graphLayout).setMaxIterations(1000);

    Dimension preferredSize = new Dimension(600, 600);
    Map<String, Point2D> map = new HashMap<String, Point2D>();
    Transformer<String, Point2D> vlf = TransformerUtils.mapTransformer(map);
    grid = this.generateVertexGrid(map, preferredSize, 25);
    gridLayout = new StaticLayout<String, Number>(grid, vlf, preferredSize);

    final VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>(
            graphLayout, preferredSize);
    vv = new VisualizationViewer<String, Number>(visualizationModel, preferredSize);

    PickedState<String> ps = vv.getPickedVertexState();
    PickedState<Number> pes = vv.getPickedEdgeState();
    vv.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(ps, Color.red, Color.yellow));
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.cyan));
    vv.setBackground(Color.white);

    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());

    final Transformer<String, Shape> ovals = vv.getRenderContext().getVertexShapeTransformer();
    final Transformer<String, Shape> squares = new ConstantTransformer(new Rectangle2D.Float(-10, -10, 20, 20));

    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller());

    Container content = getContentPane();
    GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv);
    content.add(gzsp);

    /**
     * the regular graph mouse for the normal view
     */
    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());

    hyperbolicViewSupport = new ViewLensSupport<String, Number>(vv,
            new HyperbolicShapeTransformer(vv,
                    vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)),
            new ModalLensGraphMouse());
    hyperbolicLayoutSupport = new LayoutLensSupport<String, Number>(vv,
            new HyperbolicTransformer(vv,
                    vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)),
            new ModalLensGraphMouse());
    magnifyViewSupport = new ViewLensSupport<String, Number>(vv,
            new MagnifyShapeTransformer(vv,
                    vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)),
            new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f)));
    magnifyLayoutSupport = new LayoutLensSupport<String, Number>(vv,
            new MagnifyTransformer(vv,
                    vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)),
            new ModalLensGraphMouse(new LensMagnificationGraphMousePlugin(1.f, 6.f, .2f)));
    hyperbolicLayoutSupport.getLensTransformer()
            .setLensShape(hyperbolicViewSupport.getLensTransformer().getLensShape());
    magnifyViewSupport.getLensTransformer()
            .setLensShape(hyperbolicLayoutSupport.getLensTransformer().getLensShape());
    magnifyLayoutSupport.getLensTransformer()
            .setLensShape(magnifyViewSupport.getLensTransformer().getLensShape());

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    ButtonGroup radio = new ButtonGroup();
    JRadioButton normal = new JRadioButton("None");
    normal.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                if (hyperbolicViewSupport != null) {
                    hyperbolicViewSupport.deactivate();
                }
                if (hyperbolicLayoutSupport != null) {
                    hyperbolicLayoutSupport.deactivate();
                }
                if (magnifyViewSupport != null) {
                    magnifyViewSupport.deactivate();
                }
                if (magnifyLayoutSupport != null) {
                    magnifyLayoutSupport.deactivate();
                }
            }
        }
    });

    final JRadioButton hyperView = new JRadioButton("Hyperbolic View");
    hyperView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            hyperbolicViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    final JRadioButton hyperModel = new JRadioButton("Hyperbolic Layout");
    hyperModel.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            hyperbolicLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    final JRadioButton magnifyView = new JRadioButton("Magnified View");
    magnifyView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            magnifyViewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    final JRadioButton magnifyModel = new JRadioButton("Magnified Layout");
    magnifyModel.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            magnifyLayoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    JLabel modeLabel = new JLabel("     Mode Menu >>");
    modeLabel.setUI(new VerticalLabelUI(false));
    radio.add(normal);
    radio.add(hyperModel);
    radio.add(hyperView);
    radio.add(magnifyModel);
    radio.add(magnifyView);
    normal.setSelected(true);

    graphMouse.addItemListener(hyperbolicLayoutSupport.getGraphMouse().getModeListener());
    graphMouse.addItemListener(hyperbolicViewSupport.getGraphMouse().getModeListener());
    graphMouse.addItemListener(magnifyLayoutSupport.getGraphMouse().getModeListener());
    graphMouse.addItemListener(magnifyViewSupport.getGraphMouse().getModeListener());

    ButtonGroup graphRadio = new ButtonGroup();
    JRadioButton graphButton = new JRadioButton("Graph");
    graphButton.setSelected(true);
    graphButton.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                visualizationModel.setGraphLayout(graphLayout);
                vv.getRenderContext().setVertexShapeTransformer(ovals);
                vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
                vv.repaint();
            }
        }
    });
    JRadioButton gridButton = new JRadioButton("Grid");
    gridButton.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                visualizationModel.setGraphLayout(gridLayout);
                vv.getRenderContext().setVertexShapeTransformer(squares);
                vv.getRenderContext().setVertexLabelTransformer(new ConstantTransformer(null));
                vv.repaint();
            }
        }
    });
    graphRadio.add(graphButton);
    graphRadio.add(gridButton);

    JPanel modePanel = new JPanel(new GridLayout(3, 1));
    modePanel.setBorder(BorderFactory.createTitledBorder("Display"));
    modePanel.add(graphButton);
    modePanel.add(gridButton);

    JMenuBar menubar = new JMenuBar();
    menubar.add(graphMouse.getModeMenu());
    gzsp.setCorner(menubar);

    Box controls = Box.createHorizontalBox();
    JPanel zoomControls = new JPanel(new GridLayout(2, 1));
    zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom"));
    JPanel hyperControls = new JPanel(new GridLayout(3, 2));
    hyperControls.setBorder(BorderFactory.createTitledBorder("Examiner Lens"));
    zoomControls.add(plus);
    zoomControls.add(minus);

    hyperControls.add(normal);
    hyperControls.add(new JLabel());

    hyperControls.add(hyperModel);
    hyperControls.add(magnifyModel);

    hyperControls.add(hyperView);
    hyperControls.add(magnifyView);

    controls.add(zoomControls);
    controls.add(hyperControls);
    controls.add(modePanel);
    controls.add(modeLabel);
    content.add(controls, BorderLayout.SOUTH);
}

From source file:net.sf.jhylafax.JHylaFAX.java

private void initializeMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);/*from   ww w .  ja v  a 2 s.  co  m*/

    fileMenu = new JMenu();
    menuBar.add(fileMenu);
    JComponent item = Builder.createMenuItem(sendAction);
    sendActionShortcut.setMenuItem((JMenuItem) item);
    fileMenu.add(item);
    fileMenu.add(Builder.createMenuItem(pollAction));
    fileMenu.addSeparator();
    item = Builder.createMenuItem(updateStatusAction);
    fileMenu.add(item);
    updateStatusActionShortcut.setMenuItem((JMenuItem) item);
    fileMenu.addSeparator();
    fileMenu.add(Builder.createMenuItem(settingsDialogAction));
    fileMenu.add(Builder.createMenuItem(settingsWizardAction));
    fileMenu.addSeparator();
    fileMenu.add(Builder.createMenuItem(addressBookAction));
    fileMenu.addSeparator();
    fileMenu.add(Builder.createMenuItem(exitAction));

    helpMenu = new JMenu();
    menuBar.add(helpMenu);
    helpMenu.add(Builder.createMenuItem(new WhatsThisAction()));
    helpMenu.addSeparator();
    helpMenu.add(Builder.createMenuItem(aboutAction));
}

From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java

private JMenuBar createMenuBar() {
    final JMenuBar menuBar = new JMenuBar();
    JMenuItem mItem = null;//ww  w  . jav a  2 s.  c  o m
    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:cl.almejo.vsim.gui.SimWindow.java

private void addMenu() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = newMenu(Messages.t("menu.file"), KeyEvent.VK_F, menuBar);
    menu.add(newMenuItem(NEW_ACTION, Messages.c("menu.file.new.mnemonic")));
    menu.add(newMenuItem(OPEN_ACTION, Messages.c("menu.file.open.mnemonic")));
    menu.add(newMenuItem(SAVE_ACTION, Messages.c("menu.file.save.mnemonic")));
    menu.add(newMenuItem(SAVE_AS_ACTION, Messages.c("menu.file.saveas.mnemonic")));
    menu.addSeparator();// w  w  w .j av a 2s .co  m
    menu.add(newMenuItem(QUIT_ACTION, Messages.c("menu.file.quit.mnemonic")));

    menu = newMenu(Messages.t("menu.edit"), KeyEvent.VK_F, menuBar);
    menu.add(newMenuItem(CUT_ACTION, Messages.c("menu.edit.cut.mnemonic")));
    menu.add(newMenuItem(COPY_ACTION, Messages.c("menu.edit.copy.mnemonic")));
    menu.add(newMenuItem(PASTE_ACTION, Messages.c("menu.edit.paste.mnemonic")));
    menu.add(newMenuItem(UNDO_ACTION, Messages.c("menu.edit.undo.mnemonic")));
    menu.add(newMenuItem(REDO_ACTION, Messages.c("menu.edit.redo.mnemonic")));
    menu.add(newMenuItem(PREFERENCES_ACTION, Messages.c("menu.edit.preferences.mnemonic")));

    menu = newMenu(Messages.t("menu.view"), KeyEvent.VK_V, menuBar);
    menu.add(newCheckboxMenuItem(SHOW_GRID_ACTION, Messages.c("menu.view.grid.mnemonic"), true));

    menu = newMenu(Messages.t("menu.tools"), KeyEvent.VK_H, menuBar);
    menu.add(newMenuItem(CURSOR_TOOL_ACTION, Messages.c("menu.tool.cursor.mnemonic")));
    menu.add(newMenuItem(MOVE_VIEWPORT_TOOL_ACTION, Messages.c("menu.tool.move.viewport.mnemonic")));
    menu.add(newMenuItem(WIRES_TOOL_ACTION, Messages.c("menu.tool.wires.mnemonic")));
    menu.add(newMenuItem(AND2_TOOL_ACTION, Messages.c("menu.tool.and2.mnemonic")));
    menu.add(newMenuItem(AND3_TOOL_ACTION, Messages.c("menu.tool.and3.mnemonic")));
    menu.add(newMenuItem(AND4_TOOL_ACTION, Messages.c("menu.tool.and4.mnemonic")));

    menu.add(newMenuItem(OR2_TOOL_ACTION, Messages.c("menu.tool.or2.mnemonic")));
    menu.add(newMenuItem(OR3_TOOL_ACTION, Messages.c("menu.tool.or3.mnemonic")));
    menu.add(newMenuItem(OR4_TOOL_ACTION, Messages.c("menu.tool.or4.mnemonic")));

    menu.add(newMenuItem(XOR2_TOOL_ACTION, Messages.c("menu.tool.or2.mnemonic")));
    menu.add(newMenuItem(XOR3_TOOL_ACTION, Messages.c("menu.tool.or3.mnemonic")));
    menu.add(newMenuItem(XOR4_TOOL_ACTION, Messages.c("menu.tool.or4.mnemonic")));

    menu.add(newMenuItem(CLOCK_TOOL_ACTION, Messages.c("menu.tool.clock.mnemonic")));
    menu.add(newMenuItem(NOT_TOOL_ACTION, Messages.c("menu.tool.not.mnemonic")));
    menu.add(newMenuItem(FLIP_FLOP_DATA_TOOL_ACTION, Messages.c("menu.tool.flip.flop.data.mnemonic")));
    menu.add(newMenuItem(TRISTATE_TOOL_ACTION, Messages.c("menu.tool.tristate.mnemonic")));
    menu.add(newMenuItem(SEVEN_SEGMENTS_DISPLAY_TOOL_ACTION,
            Messages.c("menu.tool.seven.segments.display.mnemonic")));
    menu.add(newMenuItem(SEVEN_SEGMENTS_DISPLAY_DOUBLE_TOOL_ACTION,
            Messages.c("menu.tool.seven.segments.display.double.mnemonic")));
    menu.add(newMenuItem(LED_TOOL_ACTION, Messages.c("menu.tool.led.mnemonic")));
    menu.add(newMenuItem(TIME_DIAGRAM_TOOL_ACTION, Messages.c("menu.tool.time.diagram.mnemonic")));
    menu.add(newMenuItem(SWITCH_TOOL_ACTION, Messages.c("menu.tool.switch.mnemonic")));

    menu = newMenu(Messages.t("menu.simulation"), KeyEvent.VK_F, menuBar);
    menu.add(newMenuItem(START_ACTION, Messages.c("menu.simulation.start.mnemonic")));
    menu.add(newMenuItem(PAUSE_ACTION, Messages.c("menu.simulation.pause.mnemonic")));

    menu = newMenu(Messages.t("menu.window"), KeyEvent.VK_F, menuBar);
    menu.add(newMenuItem(CLONE_WINDOW_ACTION, Messages.c("menu.window.clone.mnemonic")));
    menu.add(newMenuItem(CLOSE_ACTION, Messages.c("menu.window.close.mnemonic")));

    menu = newMenu(Messages.t("menu.help"), KeyEvent.VK_F, menuBar);
    menu.add(newMenuItem(ONLINE_HELP_ACTION, Messages.c("menu.help.online.mnemonic")));
    menu.add(newMenuItem(ABOUT_ACTION, Messages.c("menu.help.about.mnemonic")));

    setJMenuBar(menuBar);
}

From source file:ch.fork.AdHocRailway.ui.AdHocRailway.java

private void initMenu() {
    menuBar = new JMenuBar();
    /* FILE *//*from  ww  w  .ja v  a2 s  . c o m*/
    final JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);

    final JMenuItem newItem = new JMenuItem(new NewFileAction());
    newItem.setMnemonic(KeyEvent.VK_N);
    newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));

    final JMenuItem openItem = new JMenuItem(new OpenFileAction());
    openItem.setMnemonic(KeyEvent.VK_O);
    openItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));

    final JMenuItem openDatabaseItem = new JMenuItem(new OpenDatabaseAction());

    saveItem = new JMenuItem(new SaveAction());
    saveItem.setMnemonic(KeyEvent.VK_S);
    saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));

    saveAsItem = new JMenuItem(new SaveAsAction());
    saveAsItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));

    final JMenuItem importAllItem = new JMenuItem(new ImportAllAction());
    final JMenuItem importLocomotivesItem = new JMenuItem(new ImportLocomotivesAction());
    final JMenuItem exportLocomotivesItem = new JMenuItem(new ExportLocomotivesAction());
    final JMenuItem exportAllItem = new JMenuItem(new ExportAllAction());

    final JMenu importMenu = new JMenu("Import");
    importMenu.add(importAllItem);
    importMenu.add(importLocomotivesItem);
    final JMenu exportMenu = new JMenu("Export");
    exportMenu.add(exportLocomotivesItem);
    exportMenu.add(exportAllItem);

    final JMenuItem clearLocomotivesItem = new JMenuItem(new ClearLocomotivesAction());
    final JMenuItem clearTurnoutsRoutesItem = new JMenuItem(new ClearTurnoutsAndRoutesAction());

    final JMenu clearMenu = new JMenu("Clear");
    clearMenu.add(clearLocomotivesItem);
    clearMenu.add(clearTurnoutsRoutesItem);

    final JMenuItem exitItem = new JMenuItem(new ExitAction());
    exitItem.setMnemonic(KeyEvent.VK_X);
    exitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));

    fileMenu.add(newItem);
    fileMenu.add(openItem);
    fileMenu.add(openDatabaseItem);
    fileMenu.add(saveItem);
    fileMenu.add(saveAsItem);
    fileMenu.add(new JSeparator());
    fileMenu.add(importMenu);
    fileMenu.add(exportMenu);
    fileMenu.add(clearMenu);
    fileMenu.add(new JSeparator());
    fileMenu.add(exitItem);

    /* EDIT */
    final JMenu editMenu = new JMenu("Edit");
    enableEditing = new JCheckBoxMenuItem(new EnableEditingAction());

    switchesItem = new JMenuItem(new TurnoutAction());
    routesItem = new JMenuItem(new RoutesAction());
    locomotivesItem = new JMenuItem(new LocomotivesAction());
    preferencesItem = new JMenuItem(new PreferencesAction());
    enableEditing.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.ALT_MASK));

    switchesItem.setMnemonic(KeyEvent.VK_T);
    switchesItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.ALT_MASK));
    routesItem.setMnemonic(KeyEvent.VK_R);
    routesItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.ALT_MASK));
    locomotivesItem.setMnemonic(KeyEvent.VK_L);
    locomotivesItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, ActionEvent.ALT_MASK));
    preferencesItem.setMnemonic(KeyEvent.VK_P);
    preferencesItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.ALT_MASK));
    editMenu.add(enableEditing);
    editMenu.add(new JSeparator());
    editMenu.add(switchesItem);
    editMenu.add(routesItem);
    editMenu.add(locomotivesItem);
    editMenu.add(new JSeparator());
    editMenu.add(preferencesItem);

    /* DAEMON */
    final JMenu daemonMenu = new JMenu("Device");
    daemonConnectItem = new JMenuItem(new ConnectAction());
    daemonConnectItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
    daemonDisconnectItem = new JMenuItem(new DisconnectAction());
    daemonPowerOnItem = new JMenuItem(new PowerOnAction());
    assignAccelerator(daemonPowerOnItem, "PowerOn");
    daemonPowerOnItem.setEnabled(true);
    daemonPowerOffItem = new JMenuItem(new PowerOffAction());
    assignAccelerator(daemonPowerOffItem, "PowerOff");
    daemonPowerOffItem.setEnabled(true);
    daemonDisconnectItem.setEnabled(false);
    daemonMenu.add(daemonConnectItem);
    daemonMenu.add(daemonDisconnectItem);
    daemonMenu.add(new JSeparator());
    daemonMenu.add(daemonPowerOnItem);
    daemonMenu.add(daemonPowerOffItem);

    /* VIEW */
    final JMenu viewMenu = new JMenu("View");
    final JMenuItem refreshItem = new JMenuItem(new RefreshAction());
    final JMenuItem fullscreenItem = new JMenuItem(new ToggleFullscreenAction());

    viewMenu.add(refreshItem);
    viewMenu.add(fullscreenItem);

    /* HELP */
    // JMenu helpMenu = new JMenu("Help");
    addMenu(fileMenu);
    addMenu(editMenu);
    addMenu(daemonMenu);
    addMenu(viewMenu);
    // addMenu(helpMenu);
    setJMenuBar(menuBar);
}

From source file:lab4.YouQuiz.java

private void initComponents() {

    menuBar = new JMenuBar();
    menuBarFile = new JMenu();
    menuBarExit = new JMenuItem();
    menuBarMode = new JMenu();
    menuBarEdit = new JRadioButtonMenuItem();
    menuBarQuiz = new JRadioButtonMenuItem();
    menuBarHelp = new JMenu();
    menuBarAbout = new JMenuItem();

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setTitle("YouQuiz | Your Quiz Factory");
    setIconImage((new ImageIcon(getClass().getClassLoader().getResource("resources/icon.png"))).getImage());
    setMinimumSize(new Dimension(800, 500));
    setResizable(false);/*from w ww .  ja  v a2  s.  c o m*/

    menuBarFile.setText("File");

    menuBarExit.setAccelerator(
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK));
    menuBarExit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    menuBarExit.setText("Exit");
    menuBarFile.add(menuBarExit);

    menuBar.add(menuBarFile);

    menuBarMode.setText("Mode");

    menuBarEdit.setAccelerator(
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
    menuBarEdit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //Execute when button is pressed
            System.out.println("You clicked the button");
        }
    });
    menuBarEdit.setText("Edit Mode");

    menuBarQuiz.setAccelerator(
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK));
    menuBarQuiz.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //Execute when button is pressed
            System.out.println("You clicked the button");
        }
    });
    menuBarQuiz.setSelected(true);
    menuBarQuiz.setText("Quiz Mode");

    ButtonGroup menuBarGroup = new ButtonGroup();
    menuBarGroup.add(menuBarEdit);
    menuBarGroup.add(menuBarQuiz);

    menuBarMode.add(menuBarEdit);
    menuBarMode.add(menuBarQuiz);

    menuBar.add(menuBarMode);

    menuBarHelp.setText("Help");

    menuBarAbout.setAccelerator(
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_H, java.awt.event.InputEvent.CTRL_MASK));
    menuBarAbout.setText("About");
    menuBarAbout.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            JOptionPane.showMessageDialog(null, "By Anwar Mohamed ~ 2491", "YouQuiz",
                    JOptionPane.INFORMATION_MESSAGE,
                    new ImageIcon(getClass().getClassLoader().getResource("resources/icon-48.png")));
        }
    });
    menuBarHelp.add(menuBarAbout);

    menuBar.add(menuBarHelp);
    setJMenuBar(menuBar);

    pack();
    setLocationRelativeTo(null);
}

From source file:net.sf.jhylafax.addressbook.AddressBook.java

private void initializeMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);/* w w  w  .j a  va  2s.c o  m*/

    addressBookMenu = new JMenu();
    menuBar.add(addressBookMenu);
    addressBookMenu.add(Builder.createMenuItem(newAction));
    addressBookMenu.addSeparator();
    addressBookMenu.add(Builder.createMenuItem(editAction));
    addressBookMenu.addSeparator();
    addressBookMenu.add(Builder.createMenuItem(deleteAction));
    addressBookMenu.addSeparator();
    addressBookMenu.add(Builder.createMenuItem(importAction));
    addressBookMenu.add(Builder.createMenuItem(exportAction));
    addressBookMenu.addSeparator();
    addressBookMenu.add(Builder.createMenuItem(closeAction));
}

From source file:PrintCanvas3D.java

private JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    printItem = new JMenuItem("Print...");
    printItem.addActionListener(this);
    closeItem = new JMenuItem("Close");
    closeItem.addActionListener(this);
    fileMenu.add(printItem);//from www.jav  a2  s. c om
    fileMenu.add(new JSeparator());
    fileMenu.add(closeItem);
    menuBar.add(fileMenu);
    return menuBar;
}

From source file:core.PlanC.java

private static void configureWorkMenuBar() {
    menuBar = new JMenuBar();

    // ---------------------------------------------------------------
    // app menu - Only master user
    // ---------------------------------------------------------------
    JMenu menu = new JMenu(TStringUtils.getBundleString("about.app.id"));

    // MenuActionFactory maf = null;
    // maf = new MenuActionFactory(SystemVars.class);
    // menu.add(maf);
    // maf = new MenuActionFactory(TConnectionDialog.class);
    // maf.setDimension(MenuActionFactory.PACK_DIMMENTION);
    // menu.add(maf);
    // maf = new MenuActionFactory(TDriverDialog.class);
    // maf.setDimension(MenuActionFactory.PACK_DIMMENTION);
    // menu.add(maf);
    // menu.add(new LoadView());
    // menu.add(new SaveView());
    // menu.add(new UpdateManifestView());
    // menuBar.add(menu);

    // apend plugin actions.
    menu = new JMenu("Extensions");
    Vector<String> ip = PluginManager.getInstalledPlungin();
    for (String pic : ip) {
        String act = PluginManager.getPluginProperty(pic, "plugin.type");
        if (act.equals(Plugin.TYPE_UI)) {
            Object obj = PluginManager.getPlugin(pic).executePlugin(null);
            if (obj instanceof TAbstractAction) {
                menu.add((TAbstractAction) obj);
            }/* w  w  w .j a va 2 s. com*/
            // TODO: 180116: is necesary grant plugins more control over jmenubar. !!!!
            if (obj instanceof Vector) {
                Vector v = (Vector) obj;
                // for plancplugin, every action in vector is a main menu
                if (pic.equals("SLEPlanC")) {
                    for (Object jc : v) {
                        menuBar.add((JComponent) jc);
                    }
                } else {
                    JMenu jm = new JMenu(PluginManager.getPluginProperty(pic, "plugin.caption"));
                    for (Object aa : v) {
                        jm.add((AbstractAction) aa);
                    }
                    menu.add(jm);
                }
            }
        }
    }
    if (menu.getMenuComponentCount() > 0) {
        menuBar.add(menu);
    }

    // ---------------------------------------------------------------
    // Help
    // ---------------------------------------------------------------
    menu = new JMenu(TStringUtils.getBundleString("main.menuitem.help"));
    // g7.add(new Help());
    // menu.add(new UpdateManifestView());
    // menu.add(new JSeparator(JSeparator.HORIZONTAL));
    // menu.add(new DockingAction(Wellcome.class));
    // menu.add(new DockingAction(HelpBrowser.class));
    // HelpRecorderAction act = new HelpRecorderAction();
    // act.setEnabled(SLESession.getUserFieldValue("t_ususer_id").equals("*master"));
    // g7.add(act);
    // maf = new MenuActionFactory(AuditLog.class);
    // maf.setDimension(MenuActionFactory.LARGE_DIMMENTION);
    // menu.add(maf);
    // maf = new MenuActionFactory(References.class);
    // maf.setDimension(MenuActionFactory.LARGE_DIMMENTION);
    // menu.add(maf);

    menu.add(new About());
    menuBar.add(menu);

    // ---------------------------------------------------------------
    // user
    // ---------------------------------------------------------------

    // 171201 1.24: Mierdaaa ya es diciembre y yo pelandooooooooo otro aooo !?!?! user options moved to
    // plancselector

    // menu = new JMenu((String) Session.getUserName());
    // menu.setIcon(TResourceUtils.getSmallIcon("user_user"));
    // menu.add(new PChangePasswordAction());
    // menu.add(new SignOut());
    // menu.add(new JSeparator(JSeparator.HORIZONTAL));
    // menu.add(new Exit());
    // menuBar.add(menu);

    // ---------------------------------------------------------------
    // selector
    // ---------------------------------------------------------------
    final PlanCSelector pcs = new PlanCSelector();
    menuBar.add(pcs.getBreadcrumb());

    frame.setJMenuBar(menuBar);
}