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:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxSwing.CFEnSyntaxSwingEnAuxiliaryFinderJInternalFrame.java

public JMenuBar getFinderMenuBar() {
    if (finderMenuBar == null) {
        JMenuItem menuItem;//from ww w . ja v a 2  s. c om
        finderMenuBar = new JMenuBar();
        menuFile = new JMenu("File");
        actionAddEnAuxiliary = new ActionAddEnAuxiliary();
        menuItem = new JMenuItem(actionAddEnAuxiliary);
        menuFile.add(menuItem);
        actionViewSelected = new ActionViewSelectedEnAuxiliary();
        menuItem = new JMenuItem(actionViewSelected);
        menuFile.add(menuItem);
        actionEditSelected = new ActionEditSelectedEnAuxiliary();
        menuItem = new JMenuItem(actionEditSelected);
        menuFile.add(menuItem);
        actionDeleteSelected = new ActionDeleteSelectedEnAuxiliary();
        menuItem = new JMenuItem(actionDeleteSelected);
        menuFile.add(menuItem);
        actionClose = new ActionClose();
        menuItem = new JMenuItem(actionClose);
        menuFile.add(menuItem);
        finderMenuBar.add(menuFile);
    }
    return (finderMenuBar);
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccSwing.CFAccSwingContactListFinderJInternalFrame.java

public JMenuBar getFinderMenuBar() {
    if (finderMenuBar == null) {
        JMenuItem menuItem;//from   w w  w  . jav a2 s .  c o m
        finderMenuBar = new JMenuBar();
        menuFile = new JMenu("File");
        actionAddContactList = new ActionAddContactList();
        menuItem = new JMenuItem(actionAddContactList);
        menuFile.add(menuItem);
        actionViewSelected = new ActionViewSelectedContactList();
        menuItem = new JMenuItem(actionViewSelected);
        menuFile.add(menuItem);
        actionEditSelected = new ActionEditSelectedContactList();
        menuItem = new JMenuItem(actionEditSelected);
        menuFile.add(menuItem);
        actionDeleteSelected = new ActionDeleteSelectedContactList();
        menuItem = new JMenuItem(actionDeleteSelected);
        menuFile.add(menuItem);
        actionClose = new ActionClose();
        menuItem = new JMenuItem(actionClose);
        menuFile.add(menuItem);
        finderMenuBar.add(menuFile);
    }
    return (finderMenuBar);
}

From source file:eu.apenet.dpt.standalone.gui.DataPreparationToolGUI.java

private void setupTool() {
    LoggerJAXB.outputJaxpImplementationInfo();
    Locale currentLocale = Locale.getDefault();

    labels = new ResourceBundlesWrapper(I18N_BASENAMES, currentLocale);

    retrieveFromDb = new RetrieveFromDb();
    apePanel = new APEPanel(labels, getContentPane(), this, retrieveFromDb);

    Utilities.setXsdList(fillXsdList());

    CheckList checkList = new CheckList();
    langList = checkList.getLangList();//from   www. ja  v  a2 s .c  om
    levelList = checkList.getLevelList();

    dateNormalization = new DateNormalization();

    super.setTitle(labels.getString("title"));
    Image topLeftIcon = Utilities.icon.getImage();
    setIconImage(topLeftIcon);

    doChecks();

    if (isFileMissing(Utilities.LOG_DIR)) {
        new File(Utilities.LOG_DIR).mkdir();
    }

    File tempDir = new File(Utilities.TEMP_DIR);
    //In case it didn't deleteOnExit at the previous closing of the program, we clean up.
    if (tempDir.exists()) {
        LOG.warn("Probably a problem when deleting the temp files at closure, so we clean up");
        eraseOldTempFiles(tempDir);
        try {
            FileUtils.deleteDirectory(tempDir);
        } catch (IOException e) {
            LOG.error("Could not delete the temp directory. Attempt to delete the directory once more: "
                    + (tempDir.delete() ? "Successful." : "Unsuccessful."));
        }
    }
    tempDir.mkdir();
    tempDir.deleteOnExit();
    //        ListControlaccessTerms listControlaccessTerms = new ListControlaccessTerms("/Users/yoannmoranville/Documents/Work/APE/data/AD78/");
    //        listControlaccessTerms.countTerms();
    //        listControlaccessTerms.displayLogsResults();
    //        CountCLevels countCLevels = new CountCLevels("/Users/yoannmoranville/Work/APEnet/Projects/data/Ready_APEnet/READY/Finland/HeNAF/FA_EAD/");
    //        CountCLevels countCLevels = new CountCLevels("/Users/yoannmoranville/Work/APEnet/Projects/data/BORA/ALL/");
    //        countCLevels.setCopyInAppropriateDirs(true);
    //        countCLevels.changeMainagencycodeForSweden(false);
    //        countCLevels.countLevels();

    //        SeparateFinnishFiles separateFinnishFiles = new SeparateFinnishFiles(new File("/Users/yoannmoranville/Desktop/files_fi"), TEMP_DIR);
    makeDefaultXsdMenuItems();
    makeDefaultXslMenuItems();

    getContentPane().add(apePanel);

    xmlEadListModel = new ProfileListModel(fileInstances, this);
    xmlEadList = new JList(xmlEadListModel);
    xmlEadList.setCellRenderer(new IconListCellRenderer(fileInstances));
    xmlEadList.setDragEnabled(true);

    xmlEadList.setTransferHandler(new ListTransferHandler());

    xmlEadList.setDropTarget(new DropTarget(xmlEadList, new ListDropTargetListener(xmlEadList, from)));
    xmlEadListModel.setList(xmlEadList);

    JMenuBar menuBar = new JMenuBar();
    menuBar.add(fileMenu);
    menuBar.add(optionMenu);
    menuBar.add(actionMenu);
    menuBar.add(windowMenu);
    menuBar.add(helpMenu);
    fileItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    fileMenu.add(fileItem);

    closeSelectedItem.setEnabled(false);
    //        closeSelectedItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    closeSelectedItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    fileMenu.add(closeSelectedItem);
    saveSelectedItem.setEnabled(false);
    saveSelectedItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    fileMenu.add(saveSelectedItem);
    saveMessageReportItem.setEnabled(false);
    saveMessageReportItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    fileMenu.add(saveMessageReportItem);
    //        sendFilesWebDAV.setEnabled(false);
    //        fileMenu.add(sendFilesWebDAV);
    fileMenu.addSeparator();
    fileMenu.add(quitItem);

    optionMenu.add(countryCodeItem);
    optionMenu.add(repositoryCodeItem);
    optionMenu.add(digitalObjectTypeItem);
    optionMenu.add(edmGeneralOptionsItem);
    optionMenu.add(listDateConversionRulesItem);
    optionMenu.addSeparator();
    optionMenu.add(xsltItem);
    optionMenu.add(xsdItem);
    optionMenu.add(defaultXslSelectionSubmenu);
    optionMenu.add(defaultXsdSelectionSubmenu);
    optionMenu.addSeparator();
    optionMenu.add(checksLoadingFilesItem);
    optionMenu.add(defaultSaveFolderItem);
    optionMenu.add(languageMenu);
    if (Utilities.isDev) {
        optionMenu.addSeparator();
        optionMenu.add(databaseItem);
    }

    validateItem.setEnabled(false);
    validateItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    actionMenu.add(validateItem);
    convertItem.setEnabled(false);
    convertItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_M, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    actionMenu.add(convertItem);

    actionMenu.addSeparator();

    // TODO: Uncomment when edit will be available.
    //        eacCpfItem.add(this.editEacCpfFile);     //add the different EAC-CPF options menu
    eacCpfItem.add(createEacCpf);
    actionMenu.add(eacCpfItem);

    createEag2012Item.add(createEag2012FromExistingEag2012);
    createEag2012Item.add(createEag2012FromScratch);
    actionMenu.add(createEag2012Item);

    summaryWindowItem.setEnabled(true);
    summaryWindowItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_1, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    windowMenu.add(summaryWindowItem);
    validationWindowItem.setEnabled(true);
    validationWindowItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_2, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    windowMenu.add(validationWindowItem);
    conversionWindowItem.setEnabled(true);
    conversionWindowItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_3, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    windowMenu.add(conversionWindowItem);
    edmConversionWindowItem.setEnabled(true);
    edmConversionWindowItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_4, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    windowMenu.add(edmConversionWindowItem);
    editionWindowItem.setEnabled(true);
    editionWindowItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_5, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    windowMenu.add(editionWindowItem);
    helpMenu.add(internetApexItem);
    helpMenu.addSeparator();
    JMenuItem versionItem = new JMenuItem("APE DPT v" + VERSION_NB);
    versionItem.setEnabled(false);
    helpMenu.add(versionItem);
    createLanguageMenu();
    fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fileChooser.setMultiSelectionEnabled(true);

    getContentPane().add(menuBar, BorderLayout.NORTH);

    apePanel.setFilename("");

    createHgListener = new CreateHGListener(retrieveFromDb, labels, getContentPane(), fileInstances, xmlEadList,
            this);
    createHGBtn.addActionListener(createHgListener);
    createHGBtn.setEnabled(false);

    analyzeControlaccessListener = new AnalyzeControlaccessListener(labels, getContentPane(), fileInstances);
    analyzeControlaccessBtn.addActionListener(analyzeControlaccessListener);
    analyzeControlaccessBtn.setEnabled(false);

    validateItem.addActionListener(new ConvertAndValidateActionListener(this, apePanel.getApeTabbedPane(),
            ConvertAndValidateActionListener.VALIDATE));
    convertItem.addActionListener(new ConvertAndValidateActionListener(this, apePanel.getApeTabbedPane(),
            ConvertAndValidateActionListener.CONVERT));

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    getContentPane().add(createWest(), BorderLayout.WEST);

    //        convertAndValidateBtn.addActionListener(new ConvertAndValidateActionListener(this, getContentPane()));
    //        validateSelectionBtn.addActionListener(new ValidateSelectionActionListener(this, getContentPane()));
    //        convertEdmSelectionBtn.addActionListener(new ConvertEdmActionListener(labels, this, apePanel));

    nameComponents();
    wireUp();
    setSize(Toolkit.getDefaultToolkit().getScreenSize());
    setMinimumSize(Toolkit.getDefaultToolkit().getScreenSize());
    setExtendedState(JFrame.MAXIMIZED_BOTH);
}

From source file:com.qawaa.gui.EventWebScanGUI.java

/**
 * //from  w  w  w  . j  a  v a  2s . c o  m
 */
private void initGUI() {
    try {
        setSize(900, 600);
        {
            jMenuBar1 = new JMenuBar();
            setJMenuBar(jMenuBar1);
            {
                optionMenus = new JMenu();
                jMenuBar1.add(optionMenus);
                optionMenus.setText(CONTEXT.getMessage("gobal.menu.option", null, Locale.CHINA));
                {
                    exitMenuItem = new JMenuItem();
                    optionMenus.add(exitMenuItem);
                    exitMenuItem.setText(CONTEXT.getMessage("gobal.menu.option.quit", null, Locale.CHINA));
                    exitMenuItem.setMnemonic(KeyEvent.VK_Q);
                    exitMenuItem.setAccelerator(
                            javax.swing.KeyStroke.getKeyStroke(KeyEvent.VK_Q, Event.ALT_MASK, false));
                    exitMenuItem.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            windowsClosed();
                        }
                    });
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:PrintCanvas3D.java

private JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    snapshotItem = new JMenuItem("Snapshot");
    snapshotItem.addActionListener(this);
    printItem = new JMenuItem("Print...");
    printItem.addActionListener(this);
    quitItem = new JMenuItem("Quit");
    quitItem.addActionListener(this);
    fileMenu.add(snapshotItem);/*from  w w w .j  a v a2s .com*/
    fileMenu.add(printItem);
    fileMenu.add(new JSeparator());
    fileMenu.add(quitItem);
    menuBar.add(fileMenu);
    return menuBar;
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccSwing.CFAccSwingAccountConfigFinderJInternalFrame.java

public JMenuBar getFinderMenuBar() {
    if (finderMenuBar == null) {
        JMenuItem menuItem;//from   ww  w  .  j ava 2s. co m
        finderMenuBar = new JMenuBar();
        menuFile = new JMenu("File");
        actionAddAccountConfig = new ActionAddAccountConfig();
        menuItem = new JMenuItem(actionAddAccountConfig);
        menuFile.add(menuItem);
        actionViewSelected = new ActionViewSelectedAccountConfig();
        menuItem = new JMenuItem(actionViewSelected);
        menuFile.add(menuItem);
        actionEditSelected = new ActionEditSelectedAccountConfig();
        menuItem = new JMenuItem(actionEditSelected);
        menuFile.add(menuItem);
        actionDeleteSelected = new ActionDeleteSelectedAccountConfig();
        menuItem = new JMenuItem(actionDeleteSelected);
        menuFile.add(menuItem);
        actionClose = new ActionClose();
        menuItem = new JMenuItem(actionClose);
        menuFile.add(menuItem);
        finderMenuBar.add(menuFile);
    }
    return (finderMenuBar);
}

From source file:com.haulmont.cuba.desktop.App.java

protected Container createStartContentPane() {
    JPanel pane = new JPanel(new BorderLayout());
    menuBar = new JMenuBar();
    pane.add(menuBar, BorderLayout.NORTH);

    Locale loc = Locale.getDefault();

    JMenu menu = new JMenu(messages.getMainMessage("mainMenu.file", loc));
    menuBar.add(menu);//ww  w .  j a  va2s .c  om

    JMenuItem item;

    item = new JMenuItem(messages.getMainMessage("mainMenu.connect", loc));
    item.addActionListener(e -> showLoginDialog());
    menu.add(item);

    item = new JMenuItem(messages.getMainMessage("mainMenu.exit", loc));
    item.addActionListener(new ValidationAwareActionListener() {
        @Override
        public void actionPerformedAfterValidation(ActionEvent e) {
            exit();
        }
    });
    menu.add(item);

    if (isTestMode()) {
        menuBar.setName("startMenu");
    }

    return pane;
}

From source file:gov.nij.er.ui.EntityResolutionDemo.java

private JMenuBar buildMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    menu.add(new ExcelLoadAction());
    menu.add(new SaveParametersAction());
    menu.add(new LoadParametersAction());
    menu.add(new QuitAction());
    menuBar.add(menu);//from  www. jav  a 2 s.  co  m
    return menuBar;
}

From source file:it.cnr.icar.eric.client.ui.swing.RegistryBrowser.java

/**
 * Creates a new RegistryBrowser object.
 */// w  ww .j  a v a 2  s  .  co  m
@SuppressWarnings("unchecked")
private RegistryBrowser() {
    instance = this;

    classLoader = getClass().getClassLoader(); // new
    // JAXRBrowserClassLoader(getClass().getClassLoader());
    Thread.currentThread().setContextClassLoader(classLoader);

    /*
     * try { classLoader.loadClass("javax.xml.soap.SOAPMessage"); } catch
     * (ClassNotFoundException e) {
     * log.error("Could not find class javax.xml.soap.SOAPMessage", e); }
     */

    UIManager.addPropertyChangeListener(new UISwitchListener(getRootPane()));

    // add listener for 'locale' bound property
    addPropertyChangeListener(PROPERTY_LOCALE, this);

    menuBar = new JMenuBar();
    fileMenu = new JMenu();
    editMenu = new JMenu();
    viewMenu = new JMenu();
    helpMenu = new JMenu();

    JSeparator JSeparator1 = new JSeparator();
    newItem = new JMenuItem();
    importItem = new JMenuItem();
    saveItem = new JMenuItem();
    saveAsItem = new JMenuItem();
    exitItem = new JMenuItem();
    cutItem = new JMenuItem();
    copyItem = new JMenuItem();
    pasteItem = new JMenuItem();
    aboutItem = new JMenuItem();
    setJMenuBar(menuBar);
    setTitle(resourceBundle.getString("title.registryBrowser.java"));
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout(0, 0));

    // Scale window to be centered using 70% of screen
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

    setBounds((int) (dim.getWidth() * .15), (int) (dim.getHeight() * .1), (int) (dim.getWidth() * .7),
            (int) (dim.getHeight() * .75));
    setVisible(false);
    saveFileDialog.setMode(FileDialog.SAVE);
    saveFileDialog.setTitle(resourceBundle.getString("dialog.save.title"));

    GridBagLayout gb = new GridBagLayout();

    topPanel.setLayout(gb);
    getContentPane().add("North", topPanel);

    GridBagConstraints c = new GridBagConstraints();
    toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));
    toolbarPanel.setBounds(0, 0, 488, 29);

    discoveryToolBar = createDiscoveryToolBar();
    toolbarPanel.add(discoveryToolBar);

    // c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 0);
    gb.setConstraints(toolbarPanel, c);
    topPanel.add(toolbarPanel);

    // Panel containing context info like registry location and user context
    JPanel contextPanel = new JPanel();
    GridBagLayout gb1 = new GridBagLayout();
    contextPanel.setLayout(gb1);

    locationLabel = new JLabel(resourceBundle.getString("label.registryLocation"));

    // locationLabel.setPreferredSize(new Dimension(80, 23));
    // c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 0, 0);
    gb1.setConstraints(locationLabel, c);

    // contextPanel.setBackground(Color.green);
    contextPanel.add(locationLabel);

    selectAnItemText = new ItemText(selectAnItem);
    registryCombo.addItem(selectAnItemText.toString());

    ConfigurationType uiConfigurationType = UIUtility.getInstance().getConfigurationType();
    RegistryURIListType urlList = uiConfigurationType.getRegistryURIList();

    List<String> urls = urlList.getRegistryURI();
    Iterator<String> urlsIter = urls.iterator();
    while (urlsIter.hasNext()) {
        ItemText url = new ItemText(urlsIter.next());
        registryCombo.addItem(url.toString());
    }

    registryCombo.setEditable(true);
    registryCombo.setEnabled(true);
    registryCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            final String url = (String) registryCombo.getSelectedItem();
            if ((url == null) || (url.equals(selectAnItem))) {
                return;
            }

            // Clean tabbedPaneParent. Will create new content
            tabbedPaneParent.removeAll();
            conceptsTreeDialog = null;
            ConceptsTreeDialog.clearCache();

            // design:
            // 1. connect and construct tabbedPane in a now swing thread
            // 2. add tabbedPane in swing thread
            // 3. call reloadModel that should use WingWorkers
            final SwingWorker worker1 = new SwingWorker(RegistryBrowser.this) {
                public Object doNonUILogic() {
                    try {
                        // Try to connect
                        if (connectToRegistry(url)) {
                            return new JBTabbedPane();
                        }
                    } catch (JAXRException e1) {
                        displayError(e1);
                    }
                    return null;
                }

                public void doUIUpdateLogic() {
                    tabbedPane = (JBTabbedPane) get();
                    if (tabbedPane != null) {
                        tabbedPaneParent.add(tabbedPane, BorderLayout.CENTER);
                        tabbedPane.reloadModel();
                        try {
                            // DBH 1/30/04 - Add the submissions panel if
                            // the user is authenticated.
                            ConnectionImpl connection = RegistryBrowser.client.connection;
                            boolean newValue = connection.isAuthenticated();
                            firePropertyChange(PROPERTY_AUTHENTICATED, false, newValue);
                            getRootPane().updateUI();
                        } catch (JAXRException e1) {
                            displayError(e1);
                        }
                    }
                }
            };
            worker1.start();
        }
    });
    // c.gridx = 1;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.9;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 0, 5, 0);
    gb1.setConstraints(registryCombo, c);
    contextPanel.add(registryCombo);

    JLabel currentUserLabel = new JLabel(resourceBundle.getString("label.currentUser"),
            SwingConstants.TRAILING);
    c.gridx = 2;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 0);
    gb1.setConstraints(currentUserLabel, c);

    // contextPanel.add(currentUserLabel);
    currentUserText.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            @SuppressWarnings("unused")
            String text = currentUserText.getText();
        }
    });

    currentUserText.setEditable(false);
    c.gridx = 3;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.9;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 5, 5);
    gb1.setConstraints(currentUserText, c);

    // contextPanel.add(currentUserText);
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.9;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 0, 0, 0);
    gb.setConstraints(contextPanel, c);
    topPanel.add(contextPanel, c);

    tabbedPaneParent.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    tabbedPaneParent.setLayout(new BorderLayout());
    tabbedPaneParent.setToolTipText(resourceBundle.getString("tabbedPane.tip"));

    getContentPane().add("Center", tabbedPaneParent);

    fileMenu.setText(resourceBundle.getString("menu.file"));
    fileMenu.setActionCommand("File");
    fileMenu.setMnemonic((int) 'F');
    menuBar.add(fileMenu);

    saveItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    saveItem.setText(resourceBundle.getString("menu.save"));
    saveItem.setActionCommand("Save");
    saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK));
    saveItem.setMnemonic((int) 'S');

    // fileMenu.add(saveItem);
    fileMenu.add(JSeparator1);
    importItem.setText(resourceBundle.getString("menu.import"));
    importItem.setActionCommand("Import");
    importItem.setMnemonic((int) 'I');
    importItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            RegistryBrowser.setWaitCursor();
            importFromFile();
            RegistryBrowser.setDefaultCursor();
        }
    });
    fileMenu.add(importItem);

    exitItem.setText(resourceBundle.getString("menu.exit"));
    exitItem.setActionCommand("Exit");
    exitItem.setMnemonic((int) 'X');
    fileMenu.add(exitItem);

    editMenu.setText(resourceBundle.getString("menu.edit"));
    editMenu.setActionCommand("Edit");
    editMenu.setMnemonic((int) 'E');

    // menuBar.add(editMenu);
    cutItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    cutItem.setText(resourceBundle.getString("menu.cut"));
    cutItem.setActionCommand("Cut");
    cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK));
    cutItem.setMnemonic((int) 'T');
    editMenu.add(cutItem);

    copyItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    copyItem.setText(resourceBundle.getString("menu.copy"));
    copyItem.setActionCommand("Copy");
    copyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK));
    copyItem.setMnemonic((int) 'C');
    editMenu.add(copyItem);

    pasteItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    pasteItem.setText(resourceBundle.getString("menu.paste"));
    pasteItem.setActionCommand("Paste");
    pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK));
    pasteItem.setMnemonic((int) 'P');
    editMenu.add(pasteItem);

    viewMenu.setText(resourceBundle.getString("menu.view"));
    viewMenu.setActionCommand("view");
    viewMenu.setMnemonic((int) 'V');

    themeMenu = new MetalThemeMenu(resourceBundle.getString("menu.theme"), themes);
    viewMenu.add(themeMenu);
    menuBar.add(viewMenu);

    helpMenu.setText(resourceBundle.getString("menu.help"));
    helpMenu.setActionCommand("Help");
    helpMenu.setMnemonic((int) 'H');
    menuBar.add(helpMenu);
    aboutItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    aboutItem.setText(resourceBundle.getString("menu.about"));
    aboutItem.setActionCommand("About...");
    aboutItem.setMnemonic((int) 'A');

    aboutItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Object[] aboutArgs = { BROWSER_VERSION };
            MessageFormat form = new MessageFormat(resourceBundle.getString("dialog.about.text"));
            JOptionPane.showMessageDialog(RegistryBrowser.this, form.format(aboutArgs),
                    resourceBundle.getString("dialog.about.title"), JOptionPane.INFORMATION_MESSAGE);
        }
    });

    helpMenu.add(aboutItem);

    // REGISTER_LISTENERS
    SymWindow aSymWindow = new SymWindow();

    this.addWindowListener(aSymWindow);

    SymAction lSymAction = new SymAction();

    saveItem.addActionListener(lSymAction);
    exitItem.addActionListener(lSymAction);

    SwingUtilities.updateComponentTreeUI(getContentPane());
    SwingUtilities.updateComponentTreeUI(menuBar);
    SwingUtilities.updateComponentTreeUI(fileChooser);

    // Auto select the registry that is configured to connect to by default
    String selectedIndexStr = ProviderProperties.getInstance()
            .getProperty("jaxr-ebxml.registryBrowser.registryLocationCombo.initialSelectionIndex", "0");

    int index = Integer.parseInt(selectedIndexStr);

    try {
        registryCombo.setSelectedIndex(index);
    } catch (IllegalArgumentException e) {
        Object[] invalidIndexArguments = { new Integer(index) };
        MessageFormat form = new MessageFormat(resourceBundle.getString("message.error.invalidIndex"));
        displayError(form.format(invalidIndexArguments), e);
    }
}

From source file:com.opendoorlogistics.studio.appframe.AppFrame.java

private void initMenus(ActionFactory actionBuilder, MenuFactory menuBuilder, List<? extends Action> fileActions,
        List<? extends Action> editActions) {
    final JMenuBar menuBar = new JMenuBar();
    class AddSpace {
        void add() {
            JMenu dummy = new JMenu();
            dummy.setEnabled(false);//w  w w  . j av a2  s. com
            menuBar.add(dummy);
        }
    }
    AddSpace addSpace = new AddSpace();

    // add file menu ... build on the fly for recent files..
    setJMenuBar(menuBar);
    final JMenu mnFile = new JMenu("File");
    mnFile.setMnemonic('F');
    mnFile.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(MenuEvent e) {
            initFileMenu(mnFile, fileActions, actionBuilder, menuBuilder);
        }

        @Override
        public void menuDeselected(MenuEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void menuCanceled(MenuEvent e) {
            // TODO Auto-generated method stub

        }
    });
    initFileMenu(mnFile, fileActions, actionBuilder, menuBuilder);
    menuBar.add(mnFile);
    addSpace.add();

    // add edit menu
    JMenu mnEdit = new JMenu("Edit");
    mnEdit.setMnemonic('E');
    menuBar.add(mnEdit);
    addSpace.add();
    for (Action action : editActions) {
        mnEdit.add(action);
        //         if (action.accelerator != null) {
        //            item.setAccelerator(action.accelerator);
        //         }
    }

    // add run scripts menu (hidden until a datastore is loaded)
    mnScripts = new JMenu(appPermissions.isScriptEditingAllowed() ? "Run script" : "Run");
    mnScripts.setMnemonic('R');
    mnScripts.setVisible(false);
    mnScripts.addMenuListener(new MenuListener() {

        private void addScriptNode(JMenu parentMenu, boolean usePopupForChildren, ScriptNode node) {
            if (node.isAvailable() == false) {
                return;
            }
            if (node.isRunnable()) {
                parentMenu.add(new AbstractAction(node.getDisplayName(), node.getIcon()) {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        postScriptExecution(node.getFile(), node.getLaunchExecutorId());
                    }
                });
            } else if (node.getChildCount() > 0) {
                JMenu newParent = parentMenu;
                if (usePopupForChildren) {
                    newParent = new JMenu(node.getDisplayName());
                    parentMenu.add(newParent);
                }
                ;
                for (int i = 0; i < node.getChildCount(); i++) {
                    addScriptNode(newParent, true, (ScriptNode) node.getChildAt(i));
                }
            }
        }

        @Override
        public void menuSelected(MenuEvent e) {
            mnScripts.removeAll();
            ScriptNode[] scripts = scriptsPanel.getScripts();
            for (final ScriptNode item : scripts) {
                addScriptNode(mnScripts, scripts.length > 1, item);
            }
            mnScripts.validate();
        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });
    menuBar.add(mnScripts);
    addSpace.add();

    // add create script menu
    if (appPermissions.isScriptEditingAllowed()) {
        JMenu scriptsMenu = menuBuilder.createScriptCreationMenu(this, scriptManager);
        if (scriptsMenu != null) {
            menuBar.add(scriptsMenu);
        }
        addSpace.add();
    }

    // tools menu
    JMenu tools = new JMenu("Tools");
    menuBar.add(tools);
    JMenu memoryCache = new JMenu("Memory cache");
    tools.add(memoryCache);
    memoryCache.add(new AbstractAction("View cache statistics") {

        @Override
        public void actionPerformed(ActionEvent e) {
            TextInformationDialog dlg = new TextInformationDialog(AppFrame.this, "Memory cache statistics",
                    ApplicationCache.singleton().getUsageReport());
            dlg.setMinimumSize(new Dimension(400, 400));
            dlg.setLocationRelativeTo(AppFrame.this);
            dlg.setVisible(true);
        }
    });
    memoryCache.add(new AbstractAction("Clear memory cache") {

        @Override
        public void actionPerformed(ActionEvent e) {
            ApplicationCache.singleton().clearCache();
        }
    });
    addSpace.add();

    // add window menu
    JMenu mnWindow = menuBuilder.createWindowsMenu(this);
    mnWindow.add(new AbstractAction("Show all tables") {

        @Override
        public void actionPerformed(ActionEvent e) {
            tileTables();
        }
    });

    JMenu mnResizeTo = new JMenu("Resize application to...");
    for (final int[] size : new int[][] { new int[] { 1280, 720 }, new int[] { 1920, 1080 } }) {
        mnResizeTo.add(new AbstractAction("" + size[0] + " x " + size[1]) {

            @Override
            public void actionPerformed(ActionEvent e) {
                // set standard layout
                setSize(size[0], size[1]);
                splitterMain.setDividerLocation(0.175);
                splitterLeftSide.setDividerLocation(0.3);
            }
        });
    }
    mnWindow.add(mnResizeTo);
    menuBar.add(mnWindow);
    addSpace.add();

    menuBar.add(menuBuilder.createHelpMenu(actionBuilder, this));

    addSpace.add();

}