Search in sources :

Example 86 with JMenuBar

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

the class SignalMastLogicTableAction method setMenuBar.

/**
     * Insert a table specific Tools menu.
     * Account for the Window and Help menus, which are already added to the menu bar
     * as part of the creation of the JFrame, by adding the Tools menu 2 places earlier
     * unless the table is part of the ListedTableFrame, that adds the Help menu later on.
     * @param f the JFrame of this table
     */
@Override
public void setMenuBar(BeanTableFrame f) {
    // needed for anonymous ActionListener class
    final jmri.util.JmriJFrame finalF = f;
    JMenuBar menuBar = f.getJMenuBar();
    // count the number of menus to insert the TableMenu before 'Window' and 'Help'
    int pos = menuBar.getMenuCount() - 1;
    int offset = 1;
    log.debug("setMenuBar number of menu items = " + pos);
    for (int i = 0; i <= pos; i++) {
        if (menuBar.getComponent(i) instanceof JMenu) {
            if (((JMenu) menuBar.getComponent(i)).getText().equals(Bundle.getMessage("MenuHelp"))) {
                // correct for use as part of ListedTableAction where the Help Menu is not yet present
                offset = -1;
            }
        }
    }
    JMenu pathMenu = new JMenu(Bundle.getMessage("MenuTools"));
    menuBar.add(pathMenu, pos + offset);
    JMenuItem item = new JMenuItem(Bundle.getMessage("MenuItemAutoGen"));
    pathMenu.add(item);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            autoCreatePairs(finalF);
        }
    });
    item = new JMenuItem(Bundle.getMessage("MenuItemAutoGenSections"));
    pathMenu.add(item);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ((jmri.managers.DefaultSignalMastLogicManager) InstanceManager.getDefault(jmri.SignalMastLogicManager.class)).generateSection();
            JOptionPane.showMessageDialog(null, Bundle.getMessage("SectionGenerationComplete"));
        }
    });
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JmriJFrame(jmri.util.JmriJFrame) JMenuItem(javax.swing.JMenuItem) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 87 with JMenuBar

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

the class SignalMastTableAction method setMenuBar.

/**
     * Insert a table specific Tools menu.
     * Account for the Window and Help menus, which are already added to the menu bar
     * as part of the creation of the JFrame, by adding the Tools menu 2 places earlier
     * unless the table is part of the ListedTableFrame, that adds the Help menu later on.
     * @param f the JFrame of this table
     */
@Override
public void setMenuBar(BeanTableFrame f) {
    JMenuBar menuBar = f.getJMenuBar();
    // count the number of menus to insert the TableMenu before 'Window' and 'Help'
    int pos = menuBar.getMenuCount() - 1;
    int offset = 1;
    log.debug("setMenuBar number of menu items = " + pos);
    for (int i = 0; i <= pos; i++) {
        if (menuBar.getComponent(i) instanceof JMenu) {
            if (((JMenu) menuBar.getComponent(i)).getText().equals(Bundle.getMessage("MenuHelp"))) {
                // correct for use as part of ListedTableAction where the Help Menu is not yet present
                offset = -1;
            }
        }
    }
    JMenu pathMenu = new JMenu(Bundle.getMessage("MenuTools"));
    menuBar.add(pathMenu, pos + offset);
    JMenuItem item = new JMenuItem(Bundle.getMessage("MenuItemRepeaters"));
    pathMenu.add(item);
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            jmri.jmrit.beantable.signalmast.SignalMastRepeaterJFrame frame = new jmri.jmrit.beantable.signalmast.SignalMastRepeaterJFrame();
            frame.setVisible(true);
        }
    });
}
Also used : ActionEvent(java.awt.event.ActionEvent) ActionListener(java.awt.event.ActionListener) JMenuItem(javax.swing.JMenuItem) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 88 with JMenuBar

use of javax.swing.JMenuBar in project nhin-d by DirectProject.

the class SimpleTextPolicyBuilder method initUI.

private void initUI() {
    // build the menu bar
    menuBar = new JMenuBar();
    // build the file menu
    JMenu fileMenu = new JMenu("File");
    quit = new JMenuItem("Quit");
    save = new JMenuItem("Save");
    saveAs = new JMenuItem("SaveAs");
    openFile = new JMenuItem("Open");
    fileMenu.add(openFile);
    fileMenu.addSeparator();
    fileMenu.add(save);
    fileMenu.add(saveAs);
    //fileMenu.add(quit);
    menuBar.add(fileMenu);
    this.setJMenuBar(menuBar);
    getContentPane().setLayout(new BorderLayout());
    editPanel = new EditorPanel();
    getContentPane().add(editPanel);
}
Also used : BorderLayout(java.awt.BorderLayout) JMenuItem(javax.swing.JMenuItem) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 89 with JMenuBar

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

the class ThreePaneTLRWindow method addMainMenuBar.

protected void addMainMenuBar(String menuFile) {
    if (menuFile == null) {
        return;
    }
    JMenuBar menuBar = new JMenuBar();
    JMenu[] menus = JMenuUtil.loadMenu(menuFile, rightTopWI, null);
    for (JMenu j : menus) {
        menuBar.add(j);
    }
    setJMenuBar(menuBar);
}
Also used : JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 90 with JMenuBar

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

the class AddEntryExitPairFrame method initComponents.

/**
     * Create and set an AddEntryExitPairFrame on a given LE panel and add menuItems.
     *
     * @param panel the LE panel on which to create the NX frame
     * @throws Exception when an error prevents creating the panel
     */
public void initComponents(LayoutEditor panel) throws Exception {
    // the following code sets the frame's initial state
    nxPanel = new AddEntryExitPairPanel(panel);
    setTitle(Bundle.getMessage("AddEntryExitPoints"));
    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
    getContentPane().add(nxPanel);
    //getJMenuBar();
    JMenuBar menuBar = new JMenuBar();
    // reuse existing key in jmrit.Bundle
    JMenuItem options = new JMenuItem(Bundle.getMessage("MenuOptions"));
    menuBar.add(options);
    options.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            nxPanel.optionWindow(event);
        }
    });
    setJMenuBar(menuBar);
    addHelpMenu("package.jmri.jmrit.signalling.EntryExitFrame", true);
    // pack for display
    pack();
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JMenuItem(javax.swing.JMenuItem) 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