Search in sources :

Example 11 with JMenuBar

use of javax.swing.JMenuBar in project jgnash by ccavanaugh.

the class ActionParser method createMenuBar.

public JMenuBar createMenuBar(final String id) {
    JMenuBar menuBar = new JMenuBar();
    Object o = actionTrees.get(id);
    if (o != null) {
        ActionNode node = (ActionNode) o;
        for (int i = 0; i < node.size(); i++) {
            JMenuItem item = createMenuItem(node.getChildAt(i));
            if (item instanceof JMenu) {
                menuBar.add((JMenu) item);
            } else {
                log.log(Level.WARNING, "{0} invalid", item.toString());
            }
        }
    } else {
        log.log(Level.WARNING, "{0} not found", id);
    }
    return menuBar;
}
Also used : JMenuItem(javax.swing.JMenuItem) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 12 with JMenuBar

use of javax.swing.JMenuBar in project jdk8u_jdk by JetBrains.

the class MetalworksFrame method buildMenus.

protected void buildMenus() {
    menuBar = new JMenuBar();
    menuBar.setOpaque(true);
    JMenu file = buildFileMenu();
    JMenu edit = buildEditMenu();
    JMenu views = buildViewsMenu();
    JMenu speed = buildSpeedMenu();
    JMenu help = buildHelpMenu();
    // load a theme from a text file
    MetalTheme myTheme = null;
    try {
        InputStream istream = getClass().getResourceAsStream("/resources/MyTheme.theme");
        myTheme = new PropertiesMetalTheme(istream);
    } catch (NullPointerException e) {
        System.out.println(e);
    }
    // build an array of themes
    MetalTheme[] themes = { new OceanTheme(), new DefaultMetalTheme(), new GreenMetalTheme(), new AquaMetalTheme(), new KhakiMetalTheme(), new DemoMetalTheme(), new ContrastMetalTheme(), new BigContrastMetalTheme(), myTheme };
    // put the themes in a menu
    JMenu themeMenu = new MetalThemeMenu("Theme", themes);
    menuBar.add(file);
    menuBar.add(edit);
    menuBar.add(views);
    menuBar.add(themeMenu);
    menuBar.add(speed);
    menuBar.add(help);
    setJMenuBar(menuBar);
}
Also used : InputStream(java.io.InputStream) DefaultMetalTheme(javax.swing.plaf.metal.DefaultMetalTheme) OceanTheme(javax.swing.plaf.metal.OceanTheme) DefaultMetalTheme(javax.swing.plaf.metal.DefaultMetalTheme) MetalTheme(javax.swing.plaf.metal.MetalTheme) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 13 with JMenuBar

use of javax.swing.JMenuBar in project JMRI by JMRI.

the class JmriJFrame method addHelpMenu.

/**
     * Add a standard help menu, including window specific help item.
     *
     * @param ref    JHelp reference for the desired window-specific help page
     * @param direct true if the help menu goes directly to the help system,
     *               such as when there are no items in the help menu
     */
public void addHelpMenu(String ref, boolean direct) {
    // only works if no menu present?
    JMenuBar bar = getJMenuBar();
    if (bar == null) {
        bar = new JMenuBar();
    }
    // add Window menu
    // * GT 28-AUG-2008 Added window menu
    bar.add(new WindowMenu(this));
    // add Help menu
    jmri.util.HelpUtil.helpMenu(bar, ref, direct);
    setJMenuBar(bar);
}
Also used : JMenuBar(javax.swing.JMenuBar)

Example 14 with JMenuBar

use of javax.swing.JMenuBar in project JMRI by JMRI.

the class JmriJInternalFrameInterface method show.

@Override
public void show(final jmri.util.swing.JmriPanel child, jmri.util.swing.JmriAbstractAction act, Hint hint) {
    // create new internal frame
    JInternalFrame frame = new JInternalFrame(child.getTitle(), //resizable
    true, //closable
    true, //maximizable
    true, //iconifiable
    true);
    frame.setLocation(50, 50);
    // add gui object, responsible for own layout
    frame.add(child);
    // add menus if requested
    JMenuBar bar = frame.getJMenuBar();
    if (bar == null) {
        bar = new JMenuBar();
    }
    List<JMenu> list = child.getMenus();
    for (JMenu menu : list) {
        bar.add(menu);
    }
    // to code in JmriJFrame
    if (child.getHelpTarget() != null) {
        // add Help menu
        jmri.util.HelpUtil.helpMenu(bar, child.getHelpTarget(), true);
    }
    frame.setJMenuBar(bar);
    // set title if available
    if (child.getTitle() != null) {
        frame.setTitle(child.getTitle());
    }
    // arrange to run dispose on close
    //frame.addWindowListener( new java.awt.event.WindowAdapter(){
    //    jmri.util.swing.JmriPanel c;
    //    { c = child; }
    //    public void windowClosed(java.awt.event.WindowEvent e) {
    //        c.dispose();
    //    }
    //});
    // add to desktop
    frame.pack();
    frame.setVisible(true);
    desktop.add(frame);
    frame.moveToFront();
}
Also used : JInternalFrame(javax.swing.JInternalFrame) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 15 with JMenuBar

use of javax.swing.JMenuBar in project JMRI by JMRI.

the class JmriJFrameInterface method show.

@Override
public void show(final JmriPanel child, JmriAbstractAction act, Hint hint) {
    // display cached frame if available
    JmriJFrame frame = frames.get(child);
    if (frame != null) {
        frame.setVisible(true);
        return;
    }
    // create frame
    frame = new jmri.util.JmriJFrame();
    // cache if single instance
    if (!child.isMultipleInstances()) {
        frames.put(child, frame);
    }
    // add gui object, responsible for own layout
    frame.add(child);
    // add menus if requested
    List<JMenu> list = child.getMenus();
    JMenuBar bar = frame.getJMenuBar();
    if (bar == null) {
        bar = new JMenuBar();
    }
    for (JMenu menu : list) {
        bar.add(menu);
    }
    frame.setJMenuBar(bar);
    // add help menu if requested
    if (child.getHelpTarget() != null) {
        frame.addHelpMenu(child.getHelpTarget(), true);
    }
    // set title if available
    if (child.getTitle() != null) {
        frame.setTitle(child.getTitle());
    }
    // if multi-instance, arrange to run dispose on close
    if (child.isMultipleInstances()) {
        frame.addWindowListener(new java.awt.event.WindowAdapter() {

            jmri.util.swing.JmriPanel c;

            {
                c = child;
            }

            @Override
            public void windowClosed(java.awt.event.WindowEvent e) {
                c.dispose();
            }
        });
    }
    // pack and show
    frame.pack();
    frame.setVisible(true);
}
Also used : JmriJFrame(jmri.util.JmriJFrame) JmriJFrame(jmri.util.JmriJFrame) JmriPanel(jmri.util.swing.JmriPanel) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Aggregations

JMenuBar (javax.swing.JMenuBar)119 JMenu (javax.swing.JMenu)83 JMenuItem (javax.swing.JMenuItem)45 ActionEvent (java.awt.event.ActionEvent)36 ActionListener (java.awt.event.ActionListener)30 JPanel (javax.swing.JPanel)28 BoxLayout (javax.swing.BoxLayout)25 Dimension (java.awt.Dimension)23 JFrame (javax.swing.JFrame)17 JScrollPane (javax.swing.JScrollPane)15 JLabel (javax.swing.JLabel)14 JButton (javax.swing.JButton)13 JmriJFrame (jmri.util.JmriJFrame)12 GridBagLayout (java.awt.GridBagLayout)11 BorderLayout (java.awt.BorderLayout)10 JSeparator (javax.swing.JSeparator)10 AbstractAction (javax.swing.AbstractAction)9 FlowLayout (java.awt.FlowLayout)6 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)6 JPopupMenu (javax.swing.JPopupMenu)6