Search in sources :

Example 76 with JmriJFrame

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

the class ActivateTrainFrame method initiateTrain.

/**
     * Displays a window that allows a new ActiveTrain to be activated.
     *
     * Called by Dispatcher in response to the dispatcher clicking the New Train
     * button.
     * @param e the action event triggering the window display
     */
protected void initiateTrain(ActionEvent e) {
    // set Dispatcher defaults
    _TrainsFromRoster = _dispatcher.getTrainsFromRoster();
    _TrainsFromTrains = _dispatcher.getTrainsFromTrains();
    _TrainsFromUser = _dispatcher.getTrainsFromUser();
    _ActiveTrainsList = _dispatcher.getActiveTrainsList();
    // create window if needed
    if (initiateFrame == null) {
        initiateFrame = new JmriJFrame(Bundle.getMessage("AddTrainTitle"), false, true);
        initiateFrame.addHelpMenu("package.jmri.jmrit.dispatcher.NewTrain", true);
        initiatePane = initiateFrame.getContentPane();
        initiatePane.setLayout(new BoxLayout(initiateFrame.getContentPane(), BoxLayout.Y_AXIS));
        // add buttons to load and save train information
        JPanel p0 = new JPanel();
        p0.setLayout(new FlowLayout());
        p0.add(loadButton = new JButton(Bundle.getMessage("LoadButton")));
        loadButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                loadTrainInfo(e);
            }
        });
        loadButton.setToolTipText(Bundle.getMessage("LoadButtonHint"));
        p0.add(saveButton = new JButton(Bundle.getMessage("SaveButton")));
        saveButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                saveTrainInfo(e);
            }
        });
        saveButton.setToolTipText(Bundle.getMessage("SaveButtonHint"));
        p0.add(deleteButton = new JButton(Bundle.getMessage("ButtonDelete")));
        deleteButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                deleteTrainInfo(e);
            }
        });
        deleteButton.setToolTipText(Bundle.getMessage("DeleteButtonHint"));
        initiatePane.add(p0);
        initiatePane.add(new JSeparator());
        // add items relating to both manually run and automatic trains.
        JPanel p1 = new JPanel();
        p1.setLayout(new FlowLayout());
        p1.add(new JLabel(Bundle.getMessage("TransitBoxLabel") + " :"));
        p1.add(transitSelectBox);
        transitSelectBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                handleTransitSelectionChanged(e);
            }
        });
        transitSelectBox.setToolTipText(Bundle.getMessage("TransitBoxHint"));
        p1.add(trainBoxLabel);
        p1.add(trainSelectBox);
        trainSelectBox.setToolTipText(Bundle.getMessage("TrainBoxHint"));
        initiatePane.add(p1);
        JPanel p1a = new JPanel();
        p1a.setLayout(new FlowLayout());
        p1a.add(trainFieldLabel);
        p1a.add(trainNameField);
        trainNameField.setToolTipText(Bundle.getMessage("TrainFieldHint"));
        p1a.add(dccAddressFieldLabel);
        p1a.add(dccAddressField);
        dccAddressField.setToolTipText(Bundle.getMessage("DccAddressFieldHint"));
        initiatePane.add(p1a);
        JPanel p2 = new JPanel();
        p2.setLayout(new FlowLayout());
        p2.add(inTransitBox);
        inTransitBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                handleInTransitClick(e);
            }
        });
        inTransitBox.setToolTipText(Bundle.getMessage("InTransitBoxHint"));
        initiatePane.add(p2);
        JPanel p3 = new JPanel();
        p3.setLayout(new FlowLayout());
        p3.add(new JLabel(Bundle.getMessage("StartingBlockBoxLabel") + " :"));
        p3.add(startingBlockBox);
        startingBlockBox.setToolTipText(Bundle.getMessage("StartingBlockBoxHint"));
        startingBlockBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                handleStartingBlockSelectionChanged(e);
            }
        });
        initiatePane.add(p3);
        JPanel p4 = new JPanel();
        p4.setLayout(new FlowLayout());
        p4.add(new JLabel(Bundle.getMessage("DestinationBlockBoxLabel") + ":"));
        p4.add(destinationBlockBox);
        destinationBlockBox.setToolTipText(Bundle.getMessage("DestinationBlockBoxHint"));
        initiatePane.add(p4);
        JPanel p4a = new JPanel();
        p4a.setLayout(new FlowLayout());
        p4a.add(allocateAllTheWayBox);
        allocateAllTheWayBox.setToolTipText(Bundle.getMessage("AllocateAllTheWayBoxHint"));
        initiatePane.add(p4a);
        JPanel p6 = new JPanel();
        p6.setLayout(new FlowLayout());
        p6.add(resetWhenDoneBox);
        resetWhenDoneBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                handleResetWhenDoneClick(e);
            }
        });
        resetWhenDoneBox.setToolTipText(Bundle.getMessage("ResetWhenDoneBoxHint"));
        initiatePane.add(p6);
        JPanel p6a = new JPanel();
        p6a.setLayout(new FlowLayout());
        ((FlowLayout) p6a.getLayout()).setVgap(1);
        p6a.add(delayedReStartLabel);
        p6a.add(delayedReStartBox);
        delayedReStartBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                handleResetWhenDoneClick(e);
            }
        });
        delayedReStartBox.setToolTipText(Bundle.getMessage("DelayedReStartHint"));
        initiatePane.add(p6a);
        JPanel p6b = new JPanel();
        p6b.setLayout(new FlowLayout());
        ((FlowLayout) p6b.getLayout()).setVgap(1);
        p6b.add(delayMinLabel);
        p6b.add(delayMinField);
        delayMinField.setText("0");
        delayMinField.setToolTipText(Bundle.getMessage("RestartTimedHint"));
        p6b.add(delayReStartSensorLabel);
        p6b.add(delayReStartSensor);
        delayReStartSensor.setFirstItemBlank(true);
        handleResetWhenDoneClick(null);
        initiatePane.add(p6b);
        JPanel p10 = new JPanel();
        p10.setLayout(new FlowLayout());
        p10.add(reverseAtEndBox);
        reverseAtEndBox.setToolTipText(Bundle.getMessage("ReverseAtEndBoxHint"));
        initiatePane.add(p10);
        reverseAtEndBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                handleReverseAtEndBoxClick(e);
            }
        });
        JPanel p10a = new JPanel();
        p10a.setLayout(new FlowLayout());
        p10a.add(terminateWhenDoneBox);
        initiatePane.add(p10a);
        JPanel p8 = new JPanel();
        p8.setLayout(new FlowLayout());
        p8.add(new JLabel(Bundle.getMessage("PriorityLabel") + " :"));
        p8.add(priorityField);
        priorityField.setToolTipText(Bundle.getMessage("PriorityHint"));
        priorityField.setText("5");
        p8.add(new JLabel("     "));
        p8.add(new JLabel(Bundle.getMessage("TrainTypeBoxLabel")));
        initializeTrainTypeBox();
        p8.add(trainTypeBox);
        trainTypeBox.setSelectedIndex(1);
        trainTypeBox.setToolTipText(Bundle.getMessage("TrainTypeBoxHint"));
        initiatePane.add(p8);
        JPanel p9 = new JPanel();
        p9.setLayout(new FlowLayout());
        p9.add(new JLabel(Bundle.getMessage("DelayedStart")));
        p9.add(delayedStartBox);
        delayedStartBox.setToolTipText(Bundle.getMessage("DelayedStartHint"));
        delayedStartBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                handleDelayStartClick(e);
            }
        });
        p9.add(departureTimeLabel);
        p9.add(departureHrField);
        departureHrField.setText("08");
        departureHrField.setToolTipText(Bundle.getMessage("DepartureTimeHrHint"));
        p9.add(departureSepLabel);
        p9.add(departureMinField);
        departureMinField.setText("00");
        departureMinField.setToolTipText(Bundle.getMessage("DepartureTimeMinHint"));
        p9.add(delaySensor);
        delaySensor.setFirstItemBlank(true);
        handleDelayStartClick(null);
        initiatePane.add(p9);
        JPanel p11 = new JPanel();
        p11.setLayout(new FlowLayout());
        p11.add(loadAtStartupBox);
        loadAtStartupBox.setToolTipText(Bundle.getMessage("LoadAtStartupBoxHint"));
        loadAtStartupBox.setSelected(false);
        initiatePane.add(p11);
        initiatePane.add(new JSeparator());
        JPanel p5 = new JPanel();
        p5.setLayout(new FlowLayout());
        p5.add(autoRunBox);
        autoRunBox.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                handleAutoRunClick(e);
            }
        });
        autoRunBox.setToolTipText(Bundle.getMessage("AutoRunBoxHint"));
        autoRunBox.setSelected(false);
        initiatePane.add(p5);
        initializeAutoRunItems();
        initiatePane.add(new JSeparator());
        JPanel p7 = new JPanel();
        p7.setLayout(new FlowLayout());
        JButton cancelButton = null;
        p7.add(cancelButton = new JButton(Bundle.getMessage("ButtonCancel")));
        cancelButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                cancelInitiateTrain(e);
            }
        });
        cancelButton.setToolTipText(Bundle.getMessage("CancelButtonHint"));
        p7.add(addNewTrainButton = new JButton(Bundle.getMessage("AddNewTrainButton")));
        addNewTrainButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                addNewTrain(e);
            }
        });
        addNewTrainButton.setToolTipText(Bundle.getMessage("AddNewTrainButtonHint"));
        initiatePane.add(p7);
    }
    if (_TrainsFromRoster || _TrainsFromTrains) {
        trainBoxLabel.setVisible(true);
        trainSelectBox.setVisible(true);
        trainFieldLabel.setVisible(false);
        trainNameField.setVisible(false);
        dccAddressFieldLabel.setVisible(false);
        dccAddressField.setVisible(false);
    } else if (_TrainsFromUser) {
        trainNameField.setText("");
        trainBoxLabel.setVisible(false);
        trainSelectBox.setVisible(false);
        trainFieldLabel.setVisible(true);
        trainNameField.setVisible(true);
        dccAddressFieldLabel.setVisible(true);
        dccAddressField.setVisible(true);
    }
    setAutoRunDefaults();
    autoRunBox.setSelected(false);
    loadAtStartupBox.setSelected(false);
    allocateAllTheWayBox.setSelected(false);
    initializeFreeTransitsCombo(new ArrayList<Transit>());
    initializeFreeTrainsCombo();
    initiateFrame.pack();
    initiateFrame.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) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Transit(jmri.Transit) JSeparator(javax.swing.JSeparator)

Example 77 with JmriJFrame

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

the class Editor method locoMarkerFromRoster.

/*
     * *********************** End Popup Methods **********************
     */
/*
     * ****************** Marker Menu ***************************
     */
protected void locoMarkerFromRoster() {
    final JmriJFrame locoRosterFrame = new JmriJFrame();
    locoRosterFrame.getContentPane().setLayout(new FlowLayout());
    locoRosterFrame.setTitle(Bundle.getMessage("LocoFromRoster"));
    javax.swing.JLabel mtext = new javax.swing.JLabel();
    mtext.setText(Bundle.getMessage("SelectLoco") + ":");
    locoRosterFrame.getContentPane().add(mtext);
    final RosterEntrySelectorPanel rosterBox = new RosterEntrySelectorPanel();
    rosterBox.addPropertyChangeListener("selectedRosterEntries", new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent pce) {
            if (rosterBox.getSelectedRosterEntries().length != 0) {
                selectLoco(rosterBox.getSelectedRosterEntries()[0]);
            }
        }
    });
    locoRosterFrame.getContentPane().add(rosterBox);
    locoRosterFrame.addWindowListener(new java.awt.event.WindowAdapter() {

        @Override
        public void windowClosing(java.awt.event.WindowEvent e) {
            locoRosterFrame.dispose();
        }
    });
    locoRosterFrame.pack();
    locoRosterFrame.setVisible(true);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) FlowLayout(java.awt.FlowLayout) PropertyChangeListener(java.beans.PropertyChangeListener) JLabel(javax.swing.JLabel) JmriJFrame(jmri.util.JmriJFrame) JLabel(javax.swing.JLabel) RosterEntrySelectorPanel(jmri.jmrit.roster.swing.RosterEntrySelectorPanel)

Example 78 with JmriJFrame

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

the class MultiSensorIconFrame method initComponents.

@Override
public void initComponents() {
    this.getContentPane().setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS));
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
    p.add(new JLabel(Bundle.getMessage("IconChecksClickLabel")));
    group.add(updown);
    group.add(rightleft);
    rightleft.setSelected(true);
    p.add(rightleft);
    p.add(updown);
    this.getContentPane().add(p);
    this.getContentPane().add(content);
    content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
    // start with three Entrys; there's no reason to have less
    content.add(new Entry(content, this, "resources/icons/USS/plate/levers/l-left.gif", 1));
    content.add(new Entry(content, this, "resources/icons/USS/plate/levers/l-vertical.gif", 2));
    content.add(new Entry(content, this, "resources/icons/USS/plate/levers/l-right.gif", 3));
    this.getContentPane().add(new JSeparator());
    JButton b = new JButton(Bundle.getMessage("ButtonAddAdditionalSensor"));
    ActionListener a = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            // add another entry
            _numberOfPositions++;
            self.add(new Entry(self, frame, "resources/icons/USSpanels/Plates/lever-v.gif", _numberOfPositions));
            frame.pack();
        }

        JPanel self;

        JmriJFrame frame;

        ActionListener init(JPanel self, JmriJFrame frame) {
            this.frame = frame;
            this.self = self;
            return this;
        }
    }.init(content, this);
    b.addActionListener(a);
    this.getContentPane().add(b);
    this.getContentPane().add(new JSeparator());
    b = new JButton(Bundle.getMessage("SetStateIcons"));
    defaultIcons = new MultiIconEditor(3);
    defaultIcons.setIcon(0, Bundle.getMessage("MakeLabel", Bundle.getMessage("BeanStateUnknown")), "resources/icons/USS/plate/levers/l-inactive.gif");
    defaultIcons.setIcon(1, Bundle.getMessage("MakeLabel", Bundle.getMessage("BeanStateInconsistent")), "resources/icons/USS/plate/levers/l-unknown.gif");
    defaultIcons.setIcon(2, Bundle.getMessage("MakeLabel", Bundle.getMessage("SensorStateInactive")), "resources/icons/USS/plate/levers/l-inconsistent.gif");
    defaultIcons.complete();
    defaultsFrame = new JmriJFrame("", false, true);
    defaultsFrame.getContentPane().add(new JLabel(Bundle.getMessage("IconChangeInfo")), BorderLayout.NORTH);
    defaultsFrame.getContentPane().add(defaultIcons);
    defaultsFrame.pack();
    defaultsFrame.addHelpMenu("package.jmri.jmrit.display.MultiSensorIconDefaultsFrame", true);
    b.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            defaultsFrame.setVisible(true);
        }
    });
    this.getContentPane().add(b);
    this.getContentPane().add(new JSeparator());
    b = new JButton(Bundle.getMessage("ButtonCreateIcon"));
    b.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            make();
            if (isEmpty != 1) {
                removeWindows();
            }
        }
    });
    this.getContentPane().add(b);
}
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) JSeparator(javax.swing.JSeparator)

Example 79 with JmriJFrame

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

the class LevelXing method editLevelXing.

/**
     * Edit a Level Crossing
     */
protected void editLevelXing(LevelXing o) {
    if (editOpen) {
        editLevelXingFrame.setVisible(true);
        return;
    }
    // Initialize if needed
    if (editLevelXingFrame == null) {
        editLevelXingFrame = new JmriJFrame(rb.getString("EditXing"), false, true);
        editLevelXingFrame.addHelpMenu("package.jmri.jmrit.display.EditLevelXing", true);
        editLevelXingFrame.setLocation(50, 30);
        Container contentPane = editLevelXingFrame.getContentPane();
        contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
        JPanel panel33 = new JPanel();
        panel33.setLayout(new FlowLayout());
        hiddenBox.setToolTipText(rb.getString("HiddenToolTip"));
        panel33.add(hiddenBox);
        contentPane.add(panel33);
        // setup block 1 name
        JPanel panel1 = new JPanel();
        panel1.setLayout(new FlowLayout());
        JLabel block1NameLabel = new JLabel(Bundle.getMessage("Block_ID", 1));
        panel1.add(block1NameLabel);
        panel1.add(block1NameComboBox);
        layoutEditor.setupComboBox(block1NameComboBox, false, true);
        block1NameComboBox.setToolTipText(rb.getString("EditBlockNameHint"));
        contentPane.add(panel1);
        // setup block 2 name
        JPanel panel2 = new JPanel();
        panel2.setLayout(new FlowLayout());
        JLabel block2NameLabel = new JLabel(Bundle.getMessage("Block_ID", 2));
        panel2.add(block2NameLabel);
        panel2.add(block2NameComboBox);
        layoutEditor.setupComboBox(block2NameComboBox, false, true);
        block2NameComboBox.setToolTipText(rb.getString("EditBlockNameHint"));
        contentPane.add(panel2);
        // set up Edit 1 Block and Edit 2 Block buttons
        JPanel panel4 = new JPanel();
        panel4.setLayout(new FlowLayout());
        // Edit 1 Block
        panel4.add(xingEdit1Block = new JButton(Bundle.getMessage("EditBlock", 1)));
        xingEdit1Block.addActionListener((ActionEvent e) -> {
            xingEdit1BlockPressed(e);
        });
        // empty value for block 1
        xingEdit1Block.setToolTipText(Bundle.getMessage("EditBlockHint", ""));
        // Edit 2 Block
        panel4.add(xingEdit2Block = new JButton(Bundle.getMessage("EditBlock", 2)));
        xingEdit2Block.addActionListener((ActionEvent e) -> {
            xingEdit2BlockPressed(e);
        });
        // empty value for block 1
        xingEdit2Block.setToolTipText(Bundle.getMessage("EditBlockHint", ""));
        contentPane.add(panel4);
        // set up Done and Cancel buttons
        JPanel panel5 = new JPanel();
        panel5.setLayout(new FlowLayout());
        panel5.add(xingEditDone = new JButton(Bundle.getMessage("ButtonDone")));
        xingEditDone.addActionListener((ActionEvent e) -> {
            xingEditDonePressed(e);
        });
        xingEditDone.setToolTipText(Bundle.getMessage("DoneHint", Bundle.getMessage("ButtonDone")));
        // make this button the default button (return or enter activates)
        // Note: We have to invoke this later because we don't currently have a root pane
        SwingUtilities.invokeLater(() -> {
            JRootPane rootPane = SwingUtilities.getRootPane(xingEditDone);
            rootPane.setDefaultButton(xingEditDone);
        });
        // Cancel
        panel5.add(xingEditCancel = new JButton(Bundle.getMessage("ButtonCancel")));
        xingEditCancel.addActionListener((ActionEvent e) -> {
            xingEditCancelPressed(e);
        });
        xingEditCancel.setToolTipText(Bundle.getMessage("CancelHint", Bundle.getMessage("ButtonCancel")));
        contentPane.add(panel5);
    }
    hiddenBox.setSelected(hidden);
    // Set up for Edit
    block1NameComboBox.getEditor().setItem(blockNameAC);
    block2NameComboBox.getEditor().setItem(blockNameBD);
    editLevelXingFrame.addWindowListener(new java.awt.event.WindowAdapter() {

        @Override
        public void windowClosing(java.awt.event.WindowEvent e) {
            xingEditCancelPressed(null);
        }
    });
    editLevelXingFrame.pack();
    editLevelXingFrame.setVisible(true);
    editOpen = true;
    needsBlockUpdate = false;
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Container(java.awt.Container) JmriJFrame(jmri.util.JmriJFrame) JRootPane(javax.swing.JRootPane)

Example 80 with JmriJFrame

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

the class JythonWindow method actionPerformed.

/**
     * Invoking this action via an event triggers display of a file dialog. If a
     * file is selected, it's then invoked as a script.
     *
     */
@Override
public void actionPerformed(ActionEvent e) {
    pref = InstanceManager.getDefault(UserPreferencesManager.class);
    f = new JmriJFrame(Bundle.getMessage("TitleOutputFrame"));
    f.getContentPane().add(new JScrollPane(area = new javax.swing.JTextArea(ScriptOutput.getDefault().getOutputArea().getDocument(), null, 12, 50), ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
    // Add checkbox to enable/disable auto-scrolling
    JPanel p = new JPanel();
    p.add(clearButton = new JButton(Bundle.getMessage("ButtonClear")));
    p.add(autoScroll = new JCheckBox(Bundle.getMessage("CheckBoxAutoScroll"), true));
    autoScroll.setSelected(pref.getSimplePreferenceState(alwaysScrollCheck));
    alwaysOnTopCheckBox.setText("Window always on Top");
    alwaysOnTopCheckBox.setVisible(true);
    alwaysOnTopCheckBox.setToolTipText("If checked, this window be always be displayed in front of any other window");
    alwaysOnTopCheckBox.setSelected(pref.getSimplePreferenceState(alwaysOnTopCheck));
    p.add(alwaysOnTopCheckBox);
    f.setAlwaysOnTop(alwaysOnTopCheckBox.isSelected());
    autoScroll.addItemListener(new ItemListener() {

        // Reference to the JTextArea of this instantiation
        JTextArea ta = area;

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                doAutoScroll(ta, true);
                pref.setSimplePreferenceState(alwaysScrollCheck, autoScroll.isSelected());
            }
        }
    });
    alwaysOnTopCheckBox.addActionListener((ActionEvent ae) -> {
        f.setAlwaysOnTop(alwaysOnTopCheckBox.isSelected());
        pref.setSimplePreferenceState(alwaysOnTopCheck, alwaysOnTopCheckBox.isSelected());
    });
    clearButton.addActionListener((ActionEvent ae) -> {
        area.setText("");
    });
    f.getContentPane().add(p, BorderLayout.PAGE_END);
    // set a monospaced font
    int size = area.getFont().getSize();
    area.setFont(new Font("Monospaced", Font.PLAIN, size));
    // Add document listener to scroll to end when modified
    area.getDocument().addDocumentListener(new DocumentListener() {

        // References to the JTextArea and JCheckBox
        // of this instantiation
        JTextArea ta = area;

        JCheckBox chk = autoScroll;

        @Override
        public void insertUpdate(DocumentEvent e) {
            doAutoScroll(ta, chk.isSelected());
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            doAutoScroll(ta, chk.isSelected());
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            doAutoScroll(ta, chk.isSelected());
        }
    });
    // Scroll to end of document
    doAutoScroll(area, true);
    f.pack();
    f.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) DocumentListener(javax.swing.event.DocumentListener) ItemEvent(java.awt.event.ItemEvent) JTextArea(javax.swing.JTextArea) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) DocumentEvent(javax.swing.event.DocumentEvent) UserPreferencesManager(jmri.UserPreferencesManager) Font(java.awt.Font) JCheckBox(javax.swing.JCheckBox) JmriJFrame(jmri.util.JmriJFrame) ItemListener(java.awt.event.ItemListener) JTextArea(javax.swing.JTextArea)

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