Search in sources :

Example 26 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 27 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 28 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)

Example 29 with JmriJFrame

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

the class MrcMonPanelTest method checkAutoScrollCheckBox.

// Test checking the AutoScroll checkbox.
// for some reason the MrcMonPanel 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);
    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)

Example 30 with JmriJFrame

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

the class FileHistoryAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    JFrame frame = new JmriJFrame() {
    };
    // JmriJFrame to ensure fits on screen
    JTextArea pane = new JTextArea();
    // add a little space at top
    pane.append("\n");
    pane.setEditable(false);
    JScrollPane scroll = new JScrollPane(pane);
    frame.getContentPane().add(scroll);
    FileHistory r = InstanceManager.getNullableDefault(FileHistory.class);
    if (r == null) {
        pane.append("<No History Found>\n");
    } else {
        pane.append(r.toString());
    }
    // add a little space at bottom
    pane.append("\n");
    frame.pack();
    // start scrolled to top
    JScrollBar b = scroll.getVerticalScrollBar();
    b.setValue(b.getMaximum());
    // show
    frame.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JTextArea(javax.swing.JTextArea) JmriJFrame(jmri.util.JmriJFrame) JFrame(javax.swing.JFrame) JmriJFrame(jmri.util.JmriJFrame) FileHistory(jmri.jmrit.revhistory.FileHistory) JScrollBar(javax.swing.JScrollBar)

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