Search in sources :

Example 31 with JmriJFrame

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

the class RpsPositionIconTest method testShow.

public void testShow() {
    if (GraphicsEnvironment.isHeadless()) {
        // can't Assume in TestCase
        return;
    }
    JmriJFrame jf = new JmriJFrame("RpsPositionIcon Test");
    jf.getContentPane().setLayout(new java.awt.FlowLayout());
    RpsPositionIcon rpsIcon = new RpsPositionIcon(panel);
    jf.getContentPane().add(rpsIcon);
    // test buttons
    JButton originButton = new JButton("Set 0,0");
    originButton.addActionListener((java.awt.event.ActionEvent e) -> {
        measButtonPushed(0., 0., rpsIcon);
    });
    jf.getContentPane().add(originButton);
    JButton tentenButton = new JButton("Set 10,10");
    tentenButton.addActionListener((java.awt.event.ActionEvent e) -> {
        measButtonPushed(10., 10., rpsIcon);
    });
    jf.getContentPane().add(tentenButton);
    JButton fivetenButton = new JButton("Set 5,10");
    fivetenButton.addActionListener((java.awt.event.ActionEvent e) -> {
        measButtonPushed(5., 10., rpsIcon);
    });
    jf.getContentPane().add(fivetenButton);
    JButton loco21Button = new JButton("Loco 21");
    loco21Button.addActionListener((java.awt.event.ActionEvent e) -> {
        locoButtonPushed("21");
    });
    jf.getContentPane().add(loco21Button);
    JButton loco33Button = new JButton("Loco 33");
    loco33Button.addActionListener((java.awt.event.ActionEvent e) -> {
        locoButtonPushed("33");
    });
    jf.getContentPane().add(loco33Button);
    jf.pack();
    jf.setSize(300, 300);
    jf.setVisible(true);
    JFrame f = jmri.util.JmriJFrame.getFrame("RpsPositionIcon Test");
    Assert.assertTrue("found frame", f != null);
    f.dispose();
}
Also used : JmriJFrame(jmri.util.JmriJFrame) JmriJFrame(jmri.util.JmriJFrame) JFrame(javax.swing.JFrame) JButton(javax.swing.JButton)

Example 32 with JmriJFrame

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

the class AutomationsTableFrameTest method testFrameCreation.

@Test
public void testFrameCreation() {
    Assume.assumeFalse(GraphicsEnvironment.isHeadless());
    AutomationManager manager = AutomationManager.instance();
    Assert.assertEquals("Number of automations", 0, manager.getSize());
    AutomationsTableFrame f = new AutomationsTableFrame();
    Assert.assertNotNull("test creation", f);
    // confirm that the add automation frame isn't available
    JmriJFrame addAutomationFrame = JmriJFrame.getFrame("Add Automation");
    Assert.assertNull(addAutomationFrame);
    // now create the add automation frame
    f.addButton.doClick();
    // the following fails on a 13" laptop
    //enterClickAndLeave(f.addButton);
    addAutomationFrame = JmriJFrame.getFrame("Add Automation");
    Assert.assertNotNull(addAutomationFrame);
    addAutomationFrame.dispose();
    f.dispose();
}
Also used : JmriJFrame(jmri.util.JmriJFrame) Test(org.junit.Test)

Example 33 with JmriJFrame

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

the class AbstractMonPaneTestBase method checkAutoScrollCheckBox.

// Test checking the AutoScroll checkbox.
@Test
public void checkAutoScrollCheckBox() {
    Assume.assumeFalse(GraphicsEnvironment.isHeadless());
    AbstractMonPaneScaffold s = new AbstractMonPaneScaffold(pane);
    // for Jemmy to work, we need the pane inside of a frame
    JmriJFrame f = new JmriJFrame();
    try {
        pane.initComponents();
    } catch (Exception ex) {
        Assert.fail("Could not load pane: " + ex);
    }
    f.add(pane);
    // set title if available
    if (pane.getTitle() != null) {
        f.setTitle(pane.getTitle());
    }
    f.pack();
    f.setVisible(true);
    Assert.assertFalse(s.getAutoScrollCheckBoxValue());
    s.checkAutoScrollCheckBox();
    Assert.assertTrue(s.getAutoScrollCheckBoxValue());
    f.setVisible(false);
    f.dispose();
}
Also used : JmriJFrame(jmri.util.JmriJFrame) Test(org.junit.Test)

Example 34 with JmriJFrame

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

the class AbstractMonPaneTestBase method testFreezeButton.

@Test
public void testFreezeButton() throws Exception {
    Assume.assumeFalse(GraphicsEnvironment.isHeadless());
    AbstractMonPaneScaffold s = new AbstractMonPaneScaffold(pane);
    // for Jemmy to work, we need the pane inside of a frame
    JmriJFrame f = new JmriJFrame();
    try {
        pane.initComponents();
    } catch (Exception ex) {
        Assert.fail("Could not load pane: " + ex);
    }
    f.add(pane);
    // set title if available
    if (pane.getTitle() != null) {
        f.setTitle(pane.getTitle());
    }
    f.pack();
    f.setVisible(true);
    Assert.assertFalse(s.getFreezeButtonState());
    // there is no label on the entryField, so we access that directly.
    pane.entryField.setText("foo");
    s.clickEnterButton();
    s.clickFreezeButton();
    Assert.assertTrue(s.getFreezeButtonState());
    pane.entryField.setText("bar");
    s.clickEnterButton();
    JUnitUtil.waitFor(() -> {
        return pane.getFrameText().equals("foo\n");
    }, "frame text");
    Assert.assertEquals("foo\n", pane.getFrameText());
    f.dispose();
}
Also used : JmriJFrame(jmri.util.JmriJFrame) Test(org.junit.Test)

Example 35 with JmriJFrame

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

the class EcosMonPaneTest method checkAutoScrollCheckBox.

// Test checking the AutoScroll checkbox.
// for some reason the EcosMonPane has the checkbox value reversed on
// startup compared to other AbstractMonPane derivatives.
@Override
@Test
public void checkAutoScrollCheckBox() {
    Assume.assumeFalse(GraphicsEnvironment.isHeadless());
    AbstractMonPaneScaffold s = new AbstractMonPaneScaffold(pane);
    // for Jemmy to work, we need the pane inside of a frame
    JmriJFrame f = new JmriJFrame();
    try {
        pane.initComponents();
    } catch (Exception ex) {
        Assert.fail("Could not load pane: " + ex);
    }
    f.add(pane);
    // set title if available
    if (pane.getTitle() != null) {
        f.setTitle(pane.getTitle());
    }
    f.pack();
    f.setVisible(true);
    Assert.assertTrue(s.getAutoScrollCheckBoxValue());
    s.checkAutoScrollCheckBox();
    Assert.assertFalse(s.getAutoScrollCheckBoxValue());
    f.setVisible(false);
    f.dispose();
}
Also used : JmriJFrame(jmri.util.JmriJFrame) AbstractMonPaneScaffold(jmri.jmrix.AbstractMonPaneScaffold) Test(org.junit.Test)

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