Search in sources :

Example 86 with JmriJFrame

use of jmri.util.JmriJFrame in project JMRI by JMRI.

the class OperationsRoutesGuiTest method testRoutesTableFrame.

@Test
public void testRoutesTableFrame() {
    Assume.assumeFalse(GraphicsEnvironment.isHeadless());
    loadRoutes();
    RoutesTableFrame f = new RoutesTableFrame();
    // should be 5 rows
    Assert.assertEquals("number of rows", 5, f.routesModel.getRowCount());
    // default is sort by name
    Assert.assertEquals("1st route", "Test Route A", f.routesModel.getValueAt(0, RoutesTableModel.NAME_COLUMN));
    Assert.assertEquals("2nd route", "Test Route B", f.routesModel.getValueAt(1, RoutesTableModel.NAME_COLUMN));
    Assert.assertEquals("3rd route", "Test Route C", f.routesModel.getValueAt(2, RoutesTableModel.NAME_COLUMN));
    Assert.assertEquals("4th route", "Test Route D", f.routesModel.getValueAt(3, RoutesTableModel.NAME_COLUMN));
    Assert.assertEquals("5th route", "Test Route E", f.routesModel.getValueAt(4, RoutesTableModel.NAME_COLUMN));
    // create add route frame
    f.addButton.doClick();
    // the following fails on a 13" laptop
    //enterClickAndLeave(f.addButton);
    // confirm panel creation
    JmriJFrame ref = JmriJFrame.getFrame("Add Route");
    Assert.assertNotNull("route edit frame", ref);
    // create edit route frame
    f.routesModel.setValueAt(null, 2, RoutesTableModel.EDIT_COLUMN);
    ref.dispose();
    f.dispose();
}
Also used : JmriJFrame(jmri.util.JmriJFrame) Test(org.junit.Test)

Example 87 with JmriJFrame

use of jmri.util.JmriJFrame in project JMRI by JMRI.

the class RemoveRosterEntryToGroupAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent event) {
    frame = new JmriJFrame(Bundle.getMessage("DeleteFromGroup"));
    rosterBox = new RosterEntrySelectorPanel();
    rosterBox.getRosterGroupComboBox().setAllEntriesEnabled(false);
    frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
    JPanel p;
    p = new JPanel();
    p.setLayout(new FlowLayout());
    p.add(jLabel);
    p.add(rosterBox);
    frame.getContentPane().add(p);
    p = new JPanel();
    p.setLayout(new FlowLayout());
    p.add(okButton);
    okButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            okPressed();
        }
    });
    p.add(cancelButton);
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
    frame.getContentPane().add(p);
    frame.pack();
    frame.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionListener(java.awt.event.ActionListener) JmriJFrame(jmri.util.JmriJFrame) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout)

Example 88 with JmriJFrame

use of jmri.util.JmriJFrame in project JMRI by JMRI.

the class AddEntryExitPairPanel method optionWindow.

/**
     * Utility methods for converting between string and color. Note: These
     * names are only used internally, so don't need a resource bundle.
     *
     * @param e the action event
     */
protected void optionWindow(ActionEvent e) {
    if (optionsFrame == null) {
        optionsFrame = new JmriJFrame(Bundle.getMessage("OptionsTitle"), false, true);
        //optionsFrame.addHelpMenu("package.jmri.jmrit.dispatcher.Options", true);
        optionsPane = optionsFrame.getContentPane();
        optionsPane.setLayout(new BoxLayout(optionsFrame.getContentPane(), BoxLayout.Y_AXIS));
        clearEntry.setSelectedIndex(nxPairs.getClearDownOption());
        JPanel p1 = new JPanel();
        //clearEntry.addActionListener(clearEntryListener);
        clearEntry.setToolTipText("set the action for when the NX buttons are reselected");
        p1.add(new JLabel(Bundle.getMessage("Reselection")));
        p1.add(clearEntry);
        optionsPane.add(p1);
        JPanel p2 = new JPanel();
        initializeColorCombo(settingTrackColorBox);
        setColorCombo(settingTrackColorBox, nxPairs.getSettingRouteColor());
        ActionListener settingTrackColorListener = (ActionEvent e1) -> {
            if (getSelectedColor(settingTrackColorBox) != null) {
                durationSetting.setEnabled(true);
            } else {
                durationSetting.setEnabled(false);
            }
        };
        settingTrackColorBox.addActionListener(settingTrackColorListener);
        p2.add(new JLabel(Bundle.getMessage("RouteSetColour")));
        p2.add(settingTrackColorBox);
        optionsPane.add(p2);
        durationSetting.setText("" + nxPairs.getSettingTimer());
        if (nxPairs.useDifferentColorWhenSetting()) {
            durationSetting.setEnabled(true);
        } else {
            durationSetting.setEnabled(false);
        }
        JPanel p3 = new JPanel();
        p3.add(new JLabel(Bundle.getMessage("SettingDuration")));
        p3.add(durationSetting);
        optionsPane.add(p3);
        JPanel p4 = new JPanel();
        p4.add(dispatcherUse);
        dispatcherUse.setSelected(nxPairs.getDispatcherIntegration());
        optionsPane.add(p4);
        JButton ok = new JButton(Bundle.getMessage("ButtonOK"));
        optionsPane.add(ok);
        ok.addActionListener((ActionEvent e1) -> {
            optionSaveButton();
        });
    }
    optionsFrame.pack();
    optionsFrame.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) ActionListener(java.awt.event.ActionListener) JmriJFrame(jmri.util.JmriJFrame) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel)

Example 89 with JmriJFrame

use of jmri.util.JmriJFrame in project JMRI by JMRI.

the class PaneNewProgAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (log.isDebugEnabled()) {
        log.debug("New roster entry programmer requested");
    }
    // create the initial frame that steers
    final JmriJFrame f = new JmriJFrame(SymbolicProgBundle.getMessage("FrameNewEntrySetup"));
    f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS));
    // add the Roster menu
    JMenuBar menuBar = new JMenuBar();
    // menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));
    JMenu j = new JMenu(SymbolicProgBundle.getMessage("MenuFile"));
    j.add(new jmri.jmrit.decoderdefn.PrintDecoderListAction(SymbolicProgBundle.getMessage("MenuPrintDecoderDefinitions"), f, false));
    j.add(new jmri.jmrit.decoderdefn.PrintDecoderListAction(SymbolicProgBundle.getMessage("MenuPrintPreviewDecoderDefinitions"), f, true));
    menuBar.add(j);
    menuBar.add(new jmri.jmrit.roster.swing.RosterMenu(SymbolicProgBundle.getMessage("MenuRoster"), jmri.jmrit.roster.swing.RosterMenu.MAINMENU, f));
    f.setJMenuBar(menuBar);
    // new Loco on programming track
    JPanel pane1 = new LocoSelTreePane(null, null) {

        @Override
        protected void startProgrammer(DecoderFile decoderFile, RosterEntry re, String filename) {
            String title = SymbolicProgBundle.getMessage("FrameNewEntryTitle");
            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) LocoSelTreePane(jmri.jmrit.symbolicprog.LocoSelTreePane) JmriJFrame(jmri.util.JmriJFrame) JmriJFrame(jmri.util.JmriJFrame) JFrame(javax.swing.JFrame) RosterEntry(jmri.jmrit.roster.RosterEntry) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 90 with JmriJFrame

use of jmri.util.JmriJFrame in project JMRI by JMRI.

the class VSDPreferencesAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    // used here for the Frame Title
    JmriJFrame f = new JmriJFrame(Bundle.getMessage("VSDecoderFileMenuPreferences"), false, false);
    VSDecoderPreferencesPane tpP = new VSDecoderPreferencesPane(VSDecoderManager.instance().getVSDecoderPreferences());
    f.add(tpP);
    tpP.setContainer(f);
    f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    f.pack();
    f.setVisible(true);
    f.requestFocus();
}
Also used : JmriJFrame(jmri.util.JmriJFrame)

Aggregations

JmriJFrame (jmri.util.JmriJFrame)111 ActionEvent (java.awt.event.ActionEvent)46 BoxLayout (javax.swing.BoxLayout)44 JPanel (javax.swing.JPanel)44 JButton (javax.swing.JButton)38 ActionListener (java.awt.event.ActionListener)33 FlowLayout (java.awt.FlowLayout)30 JLabel (javax.swing.JLabel)30 Test (org.junit.Test)22 Container (java.awt.Container)20 JScrollPane (javax.swing.JScrollPane)20 JFrame (javax.swing.JFrame)16 JSeparator (javax.swing.JSeparator)10 JTable (javax.swing.JTable)10 JComboBox (javax.swing.JComboBox)9 TableColumn (javax.swing.table.TableColumn)9 TableColumnModel (javax.swing.table.TableColumnModel)9 ButtonGroup (javax.swing.ButtonGroup)8 JCheckBox (javax.swing.JCheckBox)8 JMenuBar (javax.swing.JMenuBar)8