Example usage for javax.swing JMenuBar add

List of usage examples for javax.swing JMenuBar add

Introduction

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

Prototype

public JMenu add(JMenu c) 

Source Link

Document

Appends the specified menu to the end of the menu bar.

Usage

From source file:nl.detoren.ijsco.ui.Mainscreen.java

private void addMenubar() {
    // Menu bar met 1 niveau
    Mainscreen ms = this;
    JMenuBar menubar = new JMenuBar();
    JMenu filemenu = new JMenu("Bestand");
    // File menu/*from   w ww.  ja va2 s . c  o m*/
    JMenuItem item;
    /*      item = new JMenuItem("Openen...");
          item.setAccelerator(KeyStroke.getKeyStroke('O', Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask()));
            
          item.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent arg0) {
    // Create a file chooser
    final JFileChooser fc = new JFileChooser();
    fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
    // In response to a button click:
    int returnVal = fc.showOpenDialog(ms);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
       File file = fc.getSelectedFile();
       logger.log(Level.INFO, "Opening: " + file.getAbsolutePath() + ".");
       //controller.leesBestand(file.getAbsolutePath());
       ms.repaint();
    }
             }
          });
          filemenu.add(item);
    */
    /*      item = new JMenuItem("Opslaan");
          item.setAccelerator(KeyStroke.getKeyStroke('S', Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask()));
          item.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent arg0) {
    //controller.saveState(true, "save");
             }
          });
          filemenu.add(item);
    */
    filemenu.addSeparator();
    item = new JMenuItem("Instellingen...");
    item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            actieInstellingen();
        }
    });
    item.setAccelerator(KeyStroke.getKeyStroke('I', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    filemenu.add(item);
    filemenu.addSeparator();
    item = new JMenuItem("Afsluiten");
    item.setAccelerator(KeyStroke.getKeyStroke('Q', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            controller.saveState(false, null);
            System.exit(EXIT_ON_CLOSE);
        }
    });
    filemenu.add(item);
    menubar.add(filemenu);

    /**
     *  Toernooi menu 
      */

    JMenu toernooimenu = new JMenu("Toernooi");
    item = new JMenuItem("Toernooiinformatie");
    item.setAccelerator(KeyStroke.getKeyStroke('T', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //actieNieuweSpeler(null, null);
            bewerkToernooi();
            hoofdPanel.repaint();
        }
    });
    toernooimenu.add(item);
    menubar.add(toernooimenu);

    /**
     *  Spelersdatabase menu 
      */

    JMenu spelermenu = new JMenu("Spelersdatabase");

    item = new JMenuItem("OSBO JSON lijst ophalen (Online)");
    item.setAccelerator(KeyStroke.getKeyStroke('J', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //actieNieuweSpeler(null, null);
            leeslijstOnline("www.osbo.nl", "/jeugd/currentratings.json");
            hoofdPanel.repaint();
        }
    });
    spelermenu.add(item);

    item = new JMenuItem("OSBO htmllijst ophalen !verouderd! (Online)");
    item.setAccelerator(KeyStroke.getKeyStroke('O', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //actieNieuweSpeler(null, null);
            leeslijstOnline("www.osbo.nl", "/jeugd/jrating.htm");
            hoofdPanel.repaint();
        }
    });
    spelermenu.add(item);

    item = new JMenuItem("OSBO/IJSCO compatible lijst inlezen (Bestand)");
    item.setAccelerator(KeyStroke.getKeyStroke('L', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // Create a file chooser
            final JFileChooser fc = new JFileChooser();
            fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
            // In response to a button click:
            int returnVal = fc.showOpenDialog(ms);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = fc.getSelectedFile();
                logger.log(Level.INFO, "Opening: " + file.getAbsolutePath() + ".");
                leesOSBOlijstBestand(file.getAbsolutePath());
            }
            hoofdPanel.repaint();
        }
    });
    spelermenu.add(item);

    /*      item = new JMenuItem("Groslijst CSV inlezen (Bestand) N/A");
          item.setAccelerator(KeyStroke.getKeyStroke('C', Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask()));
          item.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
    //actieNieuweSpeler(null, null);
    // Create a file chooser
    final JFileChooser fc = new JFileChooser();
    fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
    // In response to a button click:
    int returnVal = fc.showOpenDialog(ms);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
       File file = fc.getSelectedFile();
       logger.log(Level.INFO, "Opening: " + file.getAbsolutePath() + ".");
       leesCSV(file.getAbsolutePath());
    }
    hoofdPanel.repaint();
             }
          });
          spelermenu.add(item);
    */
    menubar.add(spelermenu);

    JMenu deelnemersmenu = new JMenu("Deelnemers");

    item = new JMenuItem("Wis Deelnemerslijst");
    item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // Create a file chooser
            wisDeelnemers();
            hoofdPanel.repaint();
        }
    });
    deelnemersmenu.add(item);

    item = new JMenuItem("Importeren Deelnemerslijst");
    item.setAccelerator(KeyStroke.getKeyStroke('I', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // Create a file chooser
            final JFileChooser fc = new JFileChooser();
            fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
            // In response to a button click:
            int returnVal = fc.showOpenDialog(ms);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = fc.getSelectedFile();
                logger.log(Level.INFO, "Opening: " + file.getAbsolutePath() + ".");
                leesDeelnemers(file.getAbsolutePath());
            }
            hoofdPanel.repaint();
        }
    });
    deelnemersmenu.add(item);

    item = new JMenuItem("Export Deelnemerslijst (JSON)");
    item.setAccelerator(KeyStroke.getKeyStroke('E', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // Create a file chooser
            final JFileChooser fc = new JFileChooser();
            FileNameExtensionFilter filter = new FileNameExtensionFilter("JSON", "json");
            fc.setFileFilter(filter);
            fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
            // In response to a button click:
            int returnVal = fc.showSaveDialog(ms);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = fc.getSelectedFile();
                logger.log(Level.INFO, "Opening: " + file.getAbsolutePath() + ".");
                schrijfDeelnemers(file.getAbsolutePath());
            }
            hoofdPanel.repaint();
        }
    });
    deelnemersmenu.add(item);

    menubar.add(deelnemersmenu);

    JMenu uitslagenmenu = new JMenu("Uitslagen");
    Component hs = this;
    item = new JMenuItem("Importeer uitslagenbestand");
    item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // Create a file chooser
            final JFileChooser fc = new JFileChooser();
            fc.setCurrentDirectory(new File(System.getProperty("user.dir")));

            // In response to a button click:
            int returnVal = fc.showOpenDialog(hs);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = fc.getSelectedFile();
                logger.log(Level.INFO, "Opening: " + file.getAbsolutePath() + ".");
                status.groepenuitslagen = (GroepsUitslagen) new ExcelImport().importeerUitslagen(file);
                OutputUitslagen ou = new OutputUitslagen();
                ou.exportuitslagen(status.groepenuitslagen);
                IJSCOController.t().wisUitslagen();
                ou.exportJSON(status.groepenuitslagen);
                GroepsUitslagen verwerkteUitslag = new Uitslagverwerker()
                        .verwerkUitslag(status.groepenuitslagen);
                logger.log(Level.INFO, verwerkteUitslag.ToString());
                new OutputUitslagen().exporteindresultaten(verwerkteUitslag);
                JOptionPane.showMessageDialog(null, "Uitslagen geimporteerd en bestanden aangemaakt.");
            }
            hoofdPanel.repaint();
        }
    });

    uitslagenmenu.add(item);
    menubar.add(uitslagenmenu);

    JMenu osbomenu = new JMenu("OSBO");

    item = new JMenuItem("Verstuur uitslagen handmatig.");
    item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // Create a file chooser
            SendAttachmentInEmail SAIM = new SendAttachmentInEmail();
            SAIM.sendAttachement("Uitslagen.json");
            hoofdPanel.repaint();
        }
    });

    osbomenu.add(item);
    menubar.add(osbomenu);

    JMenu helpmenu = new JMenu("Help");

    item = new JMenuItem("Verstuur logging");
    item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // Create a file chooser
            SendAttachmentInEmail SAIM = new SendAttachmentInEmail();
            SAIM.sendAttachement("IJSCO_UI.log");
            hoofdPanel.repaint();
        }
    });

    helpmenu.add(item);
    item = new JMenuItem("About");
    item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            AboutDialog ad = new AboutDialog(ms);
            ad.setVisible(true);
            hoofdPanel.repaint();
        }
    });

    helpmenu.add(item);
    menubar.add(helpmenu);

    /*      JMenu indelingMenu = new JMenu("Indeling");
          //item = new JMenuItem("Automatisch aan/uit");
          item = new JMenuItem("N/A");
          item.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent event) {
    //actieAutomatisch();
             }
          });
            
          indelingMenu.add(item);
          //item = new JMenuItem("Maak wedstrijdgroep");
          item = new JMenuItem("N/A");
          item.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
    //actieMaakWedstrijdgroep();
             }
          });
            
          indelingMenu.add(item);
          //item = new JMenuItem("Maak speelschema");
          item = new JMenuItem("N/A");
          item.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent evetn) {
    //actieMaakSpeelschema();
             }
          });
          indelingMenu.add(item);
          //item = new JMenuItem("Bewerk speelschema");
          item = new JMenuItem("N/A");
          item.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent event) {
    //updateAutomatisch(false);
    // ResultaatDialoog
    //actieBewerkSchema();
             }
          });
            
          indelingMenu.add(item);
          indelingMenu.addSeparator();
          //item = new JMenuItem("Export");
          item = new JMenuItem("N/A");
          item.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent event) {
    //actieExport();
             }
          });
          indelingMenu.add(item);
          indelingMenu.addSeparator();
          //item = new JMenuItem("Vul uitslagen in");
          item = new JMenuItem("N/A");
          item.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
    //actieVoerUitslagenIn();
             }
          });
          indelingMenu.add(item);
          //item = new JMenuItem("Externe spelers");
          item = new JMenuItem("N/A");
          item.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
    //actieExterneSpelers();
             }
          });
          indelingMenu.add(item);
          //item = new JMenuItem("Maak nieuwe stand");
          item = new JMenuItem("N/A");
          item.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
    //actieUpdateStand();
             }
          });
          indelingMenu.add(item);
          indelingMenu.addSeparator();
          //item = new JMenuItem("Volgende ronde");
          item = new JMenuItem("N/A");
          item.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
    //actieVolgendeRonde();
             }
          });
          indelingMenu.add(item);
          menubar.add(indelingMenu);
    */
    /*      JMenu overigmenu = new JMenu("Overig");
            
          //item = new JMenuItem("Reset punten");
          item = new JMenuItem("N/A");
          item.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
    //controller.resetPunten();
    hoofdPanel.repaint();
             }
          });
            
          overigmenu.add(item);
          menubar.add(overigmenu);
    */
    this.setJMenuBar(menubar);

}

From source file:no.java.ems.client.swing.EmsClient.java

private JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu();
    fileMenu.setName("menus.file");
    fileMenu.add(new DelegatingAction("new", tabs));
    fileMenu.addSeparator();//from   w w w  .j  av a2s .  c  o m
    fileMenu.add(new DelegatingAction("open", tabs));
    fileMenu.addSeparator();
    fileMenu.add(new DelegatingAction("refresh", tabs));
    fileMenu.addSeparator();
    fileMenu.add(new CloseTabAction());
    fileMenu.addSeparator();
    fileMenu.add(saveAction);
    fileMenu.addSeparator();
    fileMenu.add(logInAction);
    fileMenu.add(logOutAction);
    if (!SystemUtils.IS_OS_MAC) {
        fileMenu.addSeparator();
        fileMenu.add(exitAction);
    }
    menuBar.add(fileMenu);
    JMenu editMenu = new JMenu();
    editMenu.setName("menus.edit");
    editMenu.add(undoAction);
    editMenu.add(redoAction);
    editMenu.addSeparator();
    editMenu.add(new DelegatingAction("cut", tabs));
    editMenu.add(new DelegatingAction("copy", tabs));
    editMenu.add(new DelegatingAction("paste", tabs));
    editMenu.add(new DelegatingAction("delete", tabs));
    editMenu.addSeparator();
    editMenu.add(new DelegatingAction("addTags", tabs));
    editMenu.add(new DelegatingAction("replaceTags", tabs));
    editMenu.add(new DelegatingAction("addKeywords", tabs));
    editMenu.add(new DelegatingAction("replaceKeywords", tabs));
    menuBar.add(editMenu);
    if (SystemUtils.IS_OS_MAC) {
        for (int index = 0; index < menuBar.getMenuCount(); index++) {
            removeIcons(menuBar.getMenu(index));
        }
    }
    return menuBar;
}

From source file:nz.ac.waikato.cms.supernova.gui.Supernova.java

/**
 * Creates the menu bar.//w ww. j  a va 2 s.  com
 *
 * @return      the menu bar
 */
public JMenuBar createMenuBar() {
    JMenuBar result;
    JMenu menu;
    JMenuItem menuitem;

    result = new JMenuBar();

    menu = new JMenu("Program");
    result.add(menu);

    menuitem = new JMenuItem("Close", GUIHelper.getIcon("stop.gif"));
    menuitem.addActionListener((ActionEvent e) -> closeParent());
    menu.add(menuitem);

    menu = new JMenu("Help");
    result.add(menu);

    menuitem = new JMenuItem("Homepage", GUIHelper.getIcon("homepage.png"));
    menuitem.addActionListener(
            (ActionEvent e) -> BrowserHelper.openURL("https://github.com/fracpete/i-am-supernova"));
    menu.add(menuitem);

    return result;
}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenterTest.java

@Test
public final void testFormUtilities() {
    JFrame frame = new JFrame();
    Font theFont = new Font("Arial", Font.BOLD, 14);
    javax.swing.JMenuBar mnuMain = new JMenuBar();
    JMenu menu1 = new JMenu();
    JMenuItem menu1_1 = new JMenuItem();
    JMenuItem menu1_2 = new JMenuItem();
    JMenuItem menu1_3 = new JMenuItem();
    menu1.add(menu1_1);/*www  .j a v  a2 s.c o m*/
    menu1.add(menu1_2);
    menu1.add(menu1_3);
    JMenu menu2 = new JMenu();
    JMenuItem menu2_1 = new JMenuItem();
    JMenuItem menu2_2 = new JMenuItem();
    JMenuItem menu2_3 = new JMenuItem();
    menu1.add(menu2_1);
    menu1.add(menu2_2);
    menu1.add(menu2_3);
    JMenu menu3 = new JMenu();
    JMenuItem menu3_1 = new JMenuItem();
    JMenuItem menu3_2 = new JMenuItem();
    JMenuItem menu3_3 = new JMenuItem();
    menu1.add(menu3_1);
    menu1.add(menu3_2);
    menu1.add(menu3_3);
    frame.setJMenuBar(mnuMain);
    mnuMain.add(menu1);
    mnuMain.add(menu2);
    mnuMain.add(menu3);

    JPanel pnlTest = new JPanel();
    pnlTest.setBorder(javax.swing.BorderFactory.createTitledBorder("Test Border"));
    frame.add(pnlTest);
    JLabel label1 = new JLabel();
    JTextField text1 = new JTextField();
    pnlTest.add(label1);
    pnlTest.add(text1);
    JLabel label2 = new JLabel();
    JTextField text2 = new JTextField();
    frame.add(label2);
    frame.add(text2);

    assertFalse(menu1.getFont().equals(theFont));
    assertFalse(menu2.getFont().equals(theFont));
    assertFalse(menu3.getFont().equals(theFont));
    assertFalse(menu1_1.getFont().equals(theFont));
    assertFalse(menu1_2.getFont().equals(theFont));
    assertFalse(menu1_3.getFont().equals(theFont));
    assertFalse(menu2_1.getFont().equals(theFont));
    assertFalse(menu2_2.getFont().equals(theFont));
    assertFalse(menu2_3.getFont().equals(theFont));
    assertFalse(menu3_1.getFont().equals(theFont));
    assertFalse(menu3_2.getFont().equals(theFont));
    assertFalse(menu3_3.getFont().equals(theFont));
    assertFalse(pnlTest.getFont().equals(theFont));
    assertFalse(label1.getFont().equals(theFont));
    assertFalse(label2.getFont().equals(theFont));
    assertFalse(text1.getFont().equals(theFont));
    assertFalse(text2.getFont().equals(theFont));

    FormUtilities.setFormFont(frame, theFont);

    assertTrue(menu1.getFont().equals(theFont));
    assertTrue(menu2.getFont().equals(theFont));
    assertTrue(menu3.getFont().equals(theFont));
    assertTrue(menu1_1.getFont().equals(theFont));
    assertTrue(menu1_2.getFont().equals(theFont));
    assertTrue(menu1_3.getFont().equals(theFont));
    assertTrue(menu2_1.getFont().equals(theFont));
    assertTrue(menu2_2.getFont().equals(theFont));
    assertTrue(menu2_3.getFont().equals(theFont));
    assertTrue(menu3_1.getFont().equals(theFont));
    assertTrue(menu3_2.getFont().equals(theFont));
    assertTrue(menu3_3.getFont().equals(theFont));
    assertTrue(pnlTest.getFont().equals(theFont));
    assertTrue(label1.getFont().equals(theFont));
    assertTrue(label2.getFont().equals(theFont));
    assertTrue(text1.getFont().equals(theFont));
    assertTrue(text2.getFont().equals(theFont));
}

From source file:org.apache.cayenne.modeler.CayenneModelerFrame.java

protected void initMenus() {
    getContentPane().setLayout(new BorderLayout());

    JMenu fileMenu = new JMenu("File");
    JMenu editMenu = new JMenu("Edit");
    JMenu projectMenu = new JMenu("Project");
    JMenu toolMenu = new JMenu("Tools");
    JMenu helpMenu = new JMenu("Help");

    fileMenu.setMnemonic(KeyEvent.VK_F);
    editMenu.setMnemonic(KeyEvent.VK_E);
    projectMenu.setMnemonic(KeyEvent.VK_P);
    toolMenu.setMnemonic(KeyEvent.VK_T);
    helpMenu.setMnemonic(KeyEvent.VK_H);

    fileMenu.add(getAction(NewProjectAction.class).buildMenu());
    fileMenu.add(getAction(OpenProjectAction.class).buildMenu());
    fileMenu.add(getAction(ProjectAction.class).buildMenu());
    fileMenu.add(getAction(ImportDataMapAction.class).buildMenu());
    fileMenu.addSeparator();//from   w w  w  .jav a  2 s.co  m
    fileMenu.add(getAction(SaveAction.class).buildMenu());
    fileMenu.add(getAction(SaveAsAction.class).buildMenu());
    fileMenu.add(getAction(RevertAction.class).buildMenu());
    fileMenu.addSeparator();

    editMenu.add(getAction(UndoAction.class).buildMenu());
    editMenu.add(getAction(RedoAction.class).buildMenu());
    editMenu.add(getAction(CutAction.class).buildMenu());
    editMenu.add(getAction(CopyAction.class).buildMenu());
    editMenu.add(getAction(PasteAction.class).buildMenu());

    recentFileMenu = new RecentFileMenu("Recent Projects");
    addRecentFileListListener(recentFileMenu);
    fileMenu.add(recentFileMenu);

    fileMenu.addSeparator();
    fileMenu.add(getAction(ExitAction.class).buildMenu());

    projectMenu.add(getAction(ValidateAction.class).buildMenu());
    projectMenu.addSeparator();
    projectMenu.add(getAction(CreateNodeAction.class).buildMenu());
    projectMenu.add(getAction(CreateDataMapAction.class).buildMenu());

    projectMenu.add(getAction(CreateObjEntityAction.class).buildMenu());
    projectMenu.add(getAction(CreateEmbeddableAction.class).buildMenu());
    projectMenu.add(getAction(CreateDbEntityAction.class).buildMenu());

    projectMenu.add(getAction(CreateProcedureAction.class).buildMenu());
    projectMenu.add(getAction(CreateQueryAction.class).buildMenu());

    projectMenu.addSeparator();
    projectMenu.add(getAction(ObjEntitySyncAction.class).buildMenu());
    projectMenu.addSeparator();
    projectMenu.add(getAction(RemoveAction.class).buildMenu());

    toolMenu.add(getAction(ReverseEngineeringAction.class).buildMenu());
    toolMenu.add(getAction(InferRelationshipsAction.class).buildMenu());
    toolMenu.add(getAction(ImportEOModelAction.class).buildMenu());
    toolMenu.addSeparator();
    toolMenu.add(getAction(GenerateCodeAction.class).buildMenu());
    toolMenu.add(getAction(GenerateDBAction.class).buildMenu());
    toolMenu.add(getAction(MigrateAction.class).buildMenu());

    /**
     * Menu for opening Log console
     */
    toolMenu.addSeparator();

    logMenu = getAction(ShowLogConsoleAction.class).buildCheckBoxMenu();

    if (!LogConsole.getInstance().getConsoleProperty(LogConsole.DOCKED_PROPERTY)
            && LogConsole.getInstance().getConsoleProperty(LogConsole.SHOW_CONSOLE_PROPERTY)) {
        LogConsole.getInstance().setConsoleProperty(LogConsole.SHOW_CONSOLE_PROPERTY, false);
    }

    updateLogConsoleMenu();
    toolMenu.add(logMenu);

    toolMenu.addSeparator();
    toolMenu.add(getAction(ConfigurePreferencesAction.class).buildMenu());

    helpMenu.add(getAction(AboutAction.class).buildMenu());
    helpMenu.add(getAction(DocumentationAction.class).buildMenu());

    JMenuBar menuBar = new JMenuBar();

    menuBar.add(fileMenu);
    menuBar.add(editMenu);
    menuBar.add(projectMenu);
    menuBar.add(toolMenu);
    menuBar.add(helpMenu);

    setJMenuBar(menuBar);
}

From source file:org.apache.jackrabbit.oak.explorer.Explorer.java

private void createAndShowGUI(final File path, boolean skipSizeCheck) throws IOException {
    JTextArea log = new JTextArea(5, 20);
    log.setMargin(new Insets(5, 5, 5, 5));
    log.setLineWrap(true);//from  w  w w. ja v  a2 s .  c  om
    log.setEditable(false);

    final NodeStoreTree treePanel = new NodeStoreTree(backend, log, skipSizeCheck);

    final JFrame frame = new JFrame("Explore " + path + " @head");
    frame.addWindowListener(new java.awt.event.WindowAdapter() {
        @Override
        public void windowClosing(java.awt.event.WindowEvent windowEvent) {
            IOUtils.closeQuietly(treePanel);
            System.exit(0);
        }
    });

    JPanel content = new JPanel(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 1;

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(treePanel),
            new JScrollPane(log));
    splitPane.setDividerLocation(0.3);
    content.add(new JScrollPane(splitPane), c);
    frame.getContentPane().add(content);

    JMenuBar menuBar = new JMenuBar();
    menuBar.setMargin(new Insets(2, 2, 2, 2));

    JMenuItem menuReopen = new JMenuItem("Reopen");
    menuReopen.setMnemonic(KeyEvent.VK_R);
    menuReopen.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            try {
                treePanel.reopen();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    });

    JMenuItem menuCompaction = new JMenuItem("Time Machine");
    menuCompaction.setMnemonic(KeyEvent.VK_T);
    menuCompaction.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            List<String> revs = backend.readRevisions();
            String s = (String) JOptionPane.showInputDialog(frame, "Revert to a specified revision",
                    "Time Machine", JOptionPane.PLAIN_MESSAGE, null, revs.toArray(), revs.get(0));
            if (s != null && treePanel.revert(s)) {
                frame.setTitle("Explore " + path + " @" + s);
            }
        }
    });

    JMenuItem menuRefs = new JMenuItem("Tar File Info");
    menuRefs.setMnemonic(KeyEvent.VK_I);
    menuRefs.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            List<String> tarFiles = new ArrayList<String>();
            for (File f : path.listFiles()) {
                if (f.getName().endsWith(".tar")) {
                    tarFiles.add(f.getName());
                }
            }

            String s = (String) JOptionPane.showInputDialog(frame, "Choose a tar file", "Tar File Info",
                    JOptionPane.PLAIN_MESSAGE, null, tarFiles.toArray(), tarFiles.get(0));
            if (s != null) {
                treePanel.printTarInfo(s);
            }
        }
    });

    JMenuItem menuSCR = new JMenuItem("Segment Refs");
    menuSCR.setMnemonic(KeyEvent.VK_R);
    menuSCR.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            String s = JOptionPane.showInputDialog(frame, "Segment References\nUsage: <segmentId>",
                    "Segment References", JOptionPane.PLAIN_MESSAGE);
            if (s != null) {
                treePanel.printSegmentReferences(s);
            }
        }
    });

    JMenuItem menuDiff = new JMenuItem("SegmentNodeState diff");
    menuDiff.setMnemonic(KeyEvent.VK_D);
    menuDiff.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            String s = JOptionPane.showInputDialog(frame,
                    "SegmentNodeState diff\nUsage: <recordId> <recordId> [<path>]", "SegmentNodeState diff",
                    JOptionPane.PLAIN_MESSAGE);
            if (s != null) {
                treePanel.printDiff(s);
            }
        }
    });

    JMenuItem menuPCM = new JMenuItem("Persisted Compaction Maps");
    menuPCM.setMnemonic(KeyEvent.VK_P);
    menuPCM.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            treePanel.printPCMInfo();
        }
    });

    menuBar.add(menuReopen);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuCompaction);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuRefs);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuSCR);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuDiff);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuPCM);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));

    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setSize(960, 720);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

}

From source file:org.apache.oodt.cas.workflow.gui.WorkflowGUI.java

public JMenuBar generateMenuBar() {
    JMenuBar bar = new JMenuBar();
    FileMenu fileMenu = new FileMenu();
    bar.add(fileMenu);
    fileMenu.getExit().addActionListener(new ActionListener() {

        @Override//from ww w . ja v  a 2s .  c o  m
        public void actionPerformed(ActionEvent event) {
            System.exit(1);
        }
    });

    fileMenu.getOpenWorkspace().addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                JFileChooser chooser = new JFileChooser(new File(".")) {
                    boolean acceptFile(File f) {
                        return f.isDirectory();
                    }
                };
                chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                int value = chooser.showOpenDialog(WorkflowGUI.this);
                if (value == JFileChooser.APPROVE_OPTION) {
                    workspace = chooser.getSelectedFile();
                    updateWorkspaceText();
                    perspective.reset();
                    loadProjects();
                }
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });
    fileMenu.getImport().addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            try {
                if (workspace == null) {
                    return;
                }
                JFileChooser chooser = new JFileChooser(new File("."));
                int value = chooser.showOpenDialog(WorkflowGUI.this);
                if (value == JFileChooser.APPROVE_OPTION) {
                    File file = chooser.getSelectedFile();
                    XmlWorkflowModelRepositoryFactory factory = new XmlWorkflowModelRepositoryFactory();
                    factory.setWorkspace(workspace.getAbsolutePath());
                    View activeView = perspective.getActiveView();

                    if (activeView != null) {
                        // TODO: add code for import
                    }
                }
            } catch (Exception e) {
                LOG.log(Level.SEVERE, e.getMessage());
            }
        }

    });
    fileMenu.getNewWorkspace().addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            JFileChooser chooser = new JFileChooser(new File(".")) {
                boolean acceptFile(File f) {
                    return f.isDirectory();
                }
            };
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int value = chooser.showOpenDialog(WorkflowGUI.this);
            if (value == JFileChooser.APPROVE_OPTION) {
                workspace = chooser.getSelectedFile();
                updateWorkspaceText();
                perspective.reset();
                loadProjects();
                perspective.refresh();
            }
        }
    });

    fileMenu.getNewProject().addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            // TODO: add new project code
        }
    });
    fileMenu.getSave().addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                repo.save();
            } catch (Exception e) {
                LOG.log(Level.SEVERE, e.getMessage());
            }
        }
    });
    EditMenu editMenu = new EditMenu();
    bar.add(editMenu);
    editMenu.getUndo().addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                perspective.undo();
            } catch (Exception e) {
                LOG.log(Level.SEVERE, e.getMessage());
            }
        }
    });
    bar.revalidate();
    return bar;
}

From source file:org.apache.pdfbox.debugger.PDFDebugger.java

/**
 * This method is called from within the constructor to initialize the form.
 *//*from   w  ww  .j ava  2  s  .  co  m*/
private void initComponents() {
    jSplitPane1 = new javax.swing.JSplitPane();
    jScrollPane1 = new JScrollPane();
    tree = new Tree(this);
    jScrollPane2 = new JScrollPane();
    jTextPane1 = new javax.swing.JTextPane();

    tree.setCellRenderer(new PDFTreeCellRenderer());
    tree.setModel(null);

    setTitle("Apache PDFBox Debugger");

    addWindowListener(new java.awt.event.WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent windowEvent) {
            tree.requestFocusInWindow();
            super.windowOpened(windowEvent);
        }

        @Override
        public void windowClosing(WindowEvent evt) {
            exitForm(evt);
        }
    });

    jScrollPane1.setBorder(new BevelBorder(BevelBorder.RAISED));
    jScrollPane1.setPreferredSize(new Dimension(350, 500));
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent evt) {
            jTree1ValueChanged(evt);
        }
    });

    jScrollPane1.setViewportView(tree);

    jSplitPane1.setRightComponent(jScrollPane2);
    jSplitPane1.setDividerSize(3);

    jScrollPane2.setPreferredSize(new Dimension(300, 500));
    jScrollPane2.setViewportView(jTextPane1);

    jSplitPane1.setLeftComponent(jScrollPane1);

    JScrollPane documentScroller = new JScrollPane();
    documentScroller.setViewportView(documentPanel);

    statusPane = new TreeStatusPane(tree);
    statusPane.getPanel().setBorder(new BevelBorder(BevelBorder.RAISED));
    statusPane.getPanel().setPreferredSize(new Dimension(300, 25));
    getContentPane().add(statusPane.getPanel(), BorderLayout.PAGE_START);

    getContentPane().add(jSplitPane1, BorderLayout.CENTER);

    statusBar = new ReaderBottomPanel();
    getContentPane().add(statusBar, BorderLayout.SOUTH);

    // create menus
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(createFileMenu());
    menuBar.add(createEditMenu());
    menuBar.add(createViewMenu());
    setJMenuBar(menuBar);

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    int width = 1000;
    int height = 970;
    setBounds((screenSize.width - width) / 2, (screenSize.height - height) / 2, width, height);

    // drag and drop to open files
    setTransferHandler(new TransferHandler() {
        @Override
        public boolean canImport(TransferSupport transferSupport) {
            return transferSupport.isDataFlavorSupported(DataFlavor.javaFileListFlavor);
        }

        @Override
        @SuppressWarnings("unchecked")
        public boolean importData(TransferSupport transferSupport) {
            try {
                Transferable transferable = transferSupport.getTransferable();
                List<File> files = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
                readPDFFile(files.get(0), "");
                return true;
            } catch (IOException e) {
                new ErrorDialog(e).setVisible(true);
                return true;
            } catch (UnsupportedFlavorException e) {
                throw new RuntimeException(e);
            }
        }
    });

    // Mac OS X file open/quit handler
    if (IS_MAC_OS) {
        try {
            Method osxOpenFiles = getClass().getDeclaredMethod("osxOpenFiles", String.class);
            osxOpenFiles.setAccessible(true);
            OSXAdapter.setFileHandler(this, osxOpenFiles);

            Method osxQuit = getClass().getDeclaredMethod("osxQuit");
            osxQuit.setAccessible(true);
            OSXAdapter.setQuitHandler(this, osxQuit);
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        }
    }
}

From source file:org.apache.tika.gui.TikaGUI.java

private void addMenuBar() {
    JMenuBar bar = new JMenuBar();

    JMenu file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);
    addMenuItem(file, "Open...", "openfile", KeyEvent.VK_O);
    addMenuItem(file, "Open URL...", "openurl", KeyEvent.VK_U);
    file.addSeparator();/*from   www  .j  av a 2  s.  c om*/
    addMenuItem(file, "Exit", "exit", KeyEvent.VK_X);
    bar.add(file);

    JMenu view = new JMenu("View");
    view.setMnemonic(KeyEvent.VK_V);
    addMenuItem(view, "Metadata", "metadata", KeyEvent.VK_M);
    addMenuItem(view, "Formatted text", "html", KeyEvent.VK_F);
    addMenuItem(view, "Plain text", "text", KeyEvent.VK_P);
    addMenuItem(view, "Main content", "main", KeyEvent.VK_C);
    addMenuItem(view, "Structured text", "xhtml", KeyEvent.VK_S);
    addMenuItem(view, "Recursive JSON", "json", KeyEvent.VK_J);
    bar.add(view);

    bar.add(Box.createHorizontalGlue());
    JMenu help = new JMenu("Help");
    help.setMnemonic(KeyEvent.VK_H);
    addMenuItem(help, "About Tika", "about", KeyEvent.VK_A);
    bar.add(help);

    setJMenuBar(bar);
}

From source file:org.ayound.js.debug.ui.DebugMainFrame.java

protected JMenuBar createMenuBar() {
    final JMenuBar menuBar = new JMenuBar();

    JMenu fileMenu = new JMenu(Messages.getString("DebugMainFrame.File")); //$NON-NLS-1$
    fileMenu.setMnemonic('f');
    JMenuItem item = null;/*  ww  w .j a  v  a 2s . c  o  m*/

    item = fileMenu.add(actionOpen);
    fileMenu.add(item);

    item = fileMenu.add(actionClose);
    fileMenu.add(item);

    fileMenu.addSeparator();

    item = fileMenu.add(actionExit);
    item.setMnemonic('x');
    menuBar.add(fileMenu);

    JMenu debugMenu = new JMenu(Messages.getString("DebugMainFrame.Debug")); //$NON-NLS-1$
    debugMenu.setMnemonic('d');

    item = debugMenu.add(actionDebugStart);
    debugMenu.add(item);

    menuBar.add(debugMenu);

    item = debugMenu.add(actionDebugEnd);
    debugMenu.add(item);

    JMenu helpMenu = new JMenu(Messages.getString("DebugMainFrame.Help")); //$NON-NLS-1$
    helpMenu.setMnemonic('d');

    item = helpMenu.add(actionHelp);
    helpMenu.add(item);

    item = helpMenu.add(actionAbout);
    helpMenu.add(item);

    JMenu languageMenu = new JMenu("lauguage");

    item = languageMenu.add(actionLanguageChinese);
    languageMenu.add(item);

    item = languageMenu.add(actionLanguageEnglish);
    languageMenu.add(item);

    menuBar.add(languageMenu);

    menuBar.add(helpMenu);

    return menuBar;
}