Search in sources :

Example 26 with JMenuBar

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

the class PaneEditAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (log.isDebugEnabled()) {
        log.debug("Pane programmer requested");
    }
    // create the initial frame that steers
    final JmriJFrame f = new JmriJFrame(SymbolicProgBundle.getMessage("FrameEditEntrySetup"));
    f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS));
    // add the Roster menu
    JMenuBar menuBar = new JMenuBar();
    // menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));
    menuBar.add(new jmri.jmrit.roster.swing.RosterMenu(SymbolicProgBundle.getMessage("MenuRoster"), jmri.jmrit.roster.swing.RosterMenu.MAINMENU, f));
    f.setJMenuBar(menuBar);
    // known entry, no programmer
    JPanel pane1 = new // not programming
    KnownLocoSelPane(// not programming
    false) {

        @Override
        protected void startProgrammer(DecoderFile decoderFile, RosterEntry re, String filename) {
            String title = SymbolicProgBundle.getMessage("FrameEditEntryTitle");
            JFrame p = new PaneProgFrame(decoderFile, re, title, "programmers" + File.separator + filename + ".xml", null, false) {

                @Override
                protected JPanel getModePane() {
                    return null;
                }
            };
            p.pack();
            p.setVisible(true);
        }
    };
    // load primary frame
    pane1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
    f.getContentPane().add(pane1);
    f.pack();
    if (log.isDebugEnabled()) {
        log.debug("Tab-Programmer setup created");
    }
    f.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) DecoderFile(jmri.jmrit.decoderdefn.DecoderFile) BoxLayout(javax.swing.BoxLayout) KnownLocoSelPane(jmri.jmrit.symbolicprog.KnownLocoSelPane) JmriJFrame(jmri.util.JmriJFrame) JmriJFrame(jmri.util.JmriJFrame) JFrame(javax.swing.JFrame) RosterEntry(jmri.jmrit.roster.RosterEntry) JMenuBar(javax.swing.JMenuBar)

Example 27 with JMenuBar

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

the class ManageLocationsFrame 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,
     *               e.g. there are no items in the help menu
     *
     * WARNING: BORROWED FROM JmriJFrame.
     */
@Override
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 : WindowMenu(jmri.util.WindowMenu) JMenuBar(javax.swing.JMenuBar)

Example 28 with JMenuBar

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

the class TieToolFrame method initComponents.

@Override
public void initComponents() throws Exception {
    // set the frame's initial state
    setTitle(rb.getString("WindowTitle"));
    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    ProducerTablePane producerPane = new ProducerTablePane();
    producerPane.initComponents();
    Border producerBorder = BorderFactory.createEtchedBorder();
    Border producerTitled = BorderFactory.createTitledBorder(producerBorder, "Producers");
    producerPane.setBorder(producerTitled);
    ConsumerTablePane consumerPane = new ConsumerTablePane();
    consumerPane.initComponents();
    Border consumerBorder = BorderFactory.createEtchedBorder();
    Border consumerTitled = BorderFactory.createTitledBorder(consumerBorder, "Consumers");
    consumerPane.setBorder(consumerTitled);
    TieTablePane tiePane = new TieTablePane();
    tiePane.initComponents();
    Border tieBorder = BorderFactory.createEtchedBorder();
    Border tieTitled = BorderFactory.createTitledBorder(tieBorder, "Events");
    tiePane.setBorder(tieTitled);
    JSplitPane upperSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, producerPane, consumerPane);
    JSplitPane wholeSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upperSplit, tiePane);
    JPanel p1 = new JPanel();
    p1.add(wholeSplit);
    contentPane.add(p1);
    JPanel p2 = new JPanel();
    p2.setLayout(new FlowLayout());
    p2.add(new JButton("Add"));
    p2.add(new JButton("Update"));
    p2.add(new JButton("Delete"));
    contentPane.add(p2);
    // initialize menu bar
    JMenuBar menuBar = new JMenuBar();
    // set up File menu
    JMenu fileMenu = new JMenu("File");
    menuBar.add(fileMenu);
    // fileMenu.add(...);
    setJMenuBar(menuBar);
    addHelpMenu("package.jmri.jmrix.openlcb.swing.tie.TieToolFrame", true);
    // pack for display
    pack();
}
Also used : JPanel(javax.swing.JPanel) Container(java.awt.Container) FlowLayout(java.awt.FlowLayout) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JSplitPane(javax.swing.JSplitPane) Border(javax.swing.border.Border) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 29 with JMenuBar

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

the class ListedTableFrame method buildMenus.

void buildMenus(final TabbedTableItem item) {
    JMenuBar menuBar = new JMenuBar();
    ResourceBundle rb = ResourceBundle.getBundle("apps.AppsBundle");
    JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
    menuBar.add(fileMenu);
    JMenuItem newItem = new JMenuItem(Bundle.getMessage("MenuNewWindow"));
    fileMenu.add(newItem);
    newItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            actionList.openNewTableWindow(list.getSelectedIndex());
        }
    });
    fileMenu.add(new jmri.configurexml.SaveMenu());
    JMenuItem printItem = new JMenuItem(rb.getString("PrintTable"));
    fileMenu.add(printItem);
    printItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                // MessageFormat headerFormat = new MessageFormat(getTitle());  // not used below
                MessageFormat footerFormat = new MessageFormat(getTitle() + " page {0,number}");
                if (item.getStandardTableModel()) {
                    item.getDataTable().print(JTable.PrintMode.FIT_WIDTH, null, footerFormat);
                } else {
                    item.getAAClass().print(JTable.PrintMode.FIT_WIDTH, null, footerFormat);
                }
            } catch (java.awt.print.PrinterException e1) {
                log.warn("error printing: " + e1, e1);
            } catch (NullPointerException ex) {
                log.error("Trying to print returned a NPE error");
            }
        }
    });
    JMenu viewMenu = new JMenu(Bundle.getMessage("MenuView"));
    menuBar.add(viewMenu);
    for (int i = 0; i < TabbedTableItemListArrayArray.size(); i++) {
        final TabbedTableItemListArray itemList = TabbedTableItemListArrayArray.get(i);
        JMenuItem viewItem = new JMenuItem(itemList.getItemString());
        viewMenu.add(viewItem);
        viewItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                gotoListItem(itemList.getClassAsString());
            }
        });
    }
    this.setJMenuBar(menuBar);
    try {
        item.getAAClass().setMenuBar(this);
        this.addHelpMenu(item.getAAClass().helpTarget(), true);
    } catch (Exception ex) {
        log.error("Error when trying to set menu bar for " + item.getClassAsString() + "\n" + ex);
    }
    this.revalidate();
}
Also used : MessageFormat(java.text.MessageFormat) ActionEvent(java.awt.event.ActionEvent) ActionListener(java.awt.event.ActionListener) ResourceBundle(java.util.ResourceBundle) JMenuItem(javax.swing.JMenuItem) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 30 with JMenuBar

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

the class TurnoutTableAction method setMenuBar.

/**
     * Insert a table specific Operations 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 Operations 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();
    // check for menu
    boolean menuAbsent = true;
    for (int m = 0; m < menuBar.getMenuCount(); ++m) {
        String name = menuBar.getMenu(m).getAccessibleContext().getAccessibleName();
        if (name.equals(Bundle.getMessage("TurnoutAutomationMenu"))) {
            // using first menu for check, should be identical to next JMenu Bundle
            menuAbsent = false;
            break;
        }
    }
    if (menuAbsent) {
        // create it
        // 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 opsMenu = new JMenu(Bundle.getMessage("TurnoutAutomationMenu"));
        JMenuItem item = new JMenuItem(Bundle.getMessage("TurnoutAutomationMenuItemEdit"));
        opsMenu.add(item);
        item.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                new TurnoutOperationFrame(finalF);
            }
        });
        menuBar.add(opsMenu, pos + offset);
        JMenu speedMenu = new JMenu(Bundle.getMessage("SpeedsMenu"));
        item = new JMenuItem(Bundle.getMessage("SpeedsMenuItemDefaults"));
        speedMenu.add(item);
        item.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                setDefaultSpeeds(finalF);
            }
        });
        // add this menu to the right of the previous
        menuBar.add(speedMenu, pos + offset + 1);
    }
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) TurnoutOperationFrame(jmri.jmrit.turnoutoperations.TurnoutOperationFrame) JmriJFrame(jmri.util.JmriJFrame) JMenuItem(javax.swing.JMenuItem) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

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