use of jmri.util.JmriJFrame in project JMRI by JMRI.
the class LocoStatsPanel method notifyChangedInterfaceStatus.
/**
* Listener for LocoNet Interface Status changes
*
* @param o a LocoNetStatus object
*/
@Override
@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "GUI elements are created such that cast to JmriJFrame this is accurate")
public void notifyChangedInterfaceStatus(Object o) {
// NOI18N
log.debug("Update is being handled:" + o.toString());
if (!updateRequestPending) {
return;
}
if (o.getClass() == LocoBufferIIStatus.class) {
LocoBufferIIStatus s = (LocoBufferIIStatus) o;
version.setText((Integer.toHexString(s.version)));
breaks.setText((Integer.toString(s.breaks)));
errors.setText((Integer.toString(s.errors)));
lb2Panel.setVisible(true);
rawPanel.setVisible(false);
ms100Panel.setVisible(false);
pr2Panel.setVisible(false);
((JmriJFrame) getRootPane().getParent()).setPreferredSize(null);
((JmriJFrame) getRootPane().getParent()).pack();
} else if (o.getClass() == PR2Status.class) {
PR2Status s = (PR2Status) o;
serial.setText(Integer.toString(s.serial));
status.setText(Integer.toString(s.status));
current.setText(Integer.toString(s.current));
hardware.setText(Integer.toString(s.hardware));
software.setText(Integer.toString(s.software));
lb2Panel.setVisible(false);
rawPanel.setVisible(false);
ms100Panel.setVisible(true);
pr2Panel.setVisible(true);
((JmriJFrame) getRootPane().getParent()).setPreferredSize(null);
((JmriJFrame) getRootPane().getParent()).pack();
} else if (o.getClass() == PR3MS100ModeStatus.class) {
PR3MS100ModeStatus s = (PR3MS100ModeStatus) o;
goodMsgCnt.setText(Integer.toString(s.goodMsgCnt));
badMsgCnt.setText(Integer.toString(s.badMsgCnt));
ms100status.setText(Integer.toString(s.ms100status));
lb2Panel.setVisible(false);
rawPanel.setVisible(false);
ms100Panel.setVisible(true);
pr2Panel.setVisible(true);
((JmriJFrame) getRootPane().getParent()).setPreferredSize(null);
((JmriJFrame) getRootPane().getParent()).pack();
} else if (o.getClass() == RawStatus.class) {
RawStatus s = (RawStatus) o;
r1.setText(Integer.toString(s.raw[0]));
r2.setText(Integer.toString(s.raw[1]));
r3.setText(Integer.toString(s.raw[2]));
r4.setText(Integer.toString(s.raw[3]));
r5.setText(Integer.toString(s.raw[4]));
r6.setText(Integer.toString(s.raw[5]));
r7.setText(Integer.toString(s.raw[6]));
r8.setText(Integer.toString(s.raw[7]));
lb2Panel.setVisible(false);
rawPanel.setVisible(true);
ms100Panel.setVisible(false);
pr2Panel.setVisible(false);
((JmriJFrame) getRootPane().getParent()).setPreferredSize(null);
((JmriJFrame) getRootPane().getParent()).pack();
}
}
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);
}
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;
}
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);
}
use of jmri.util.JmriJFrame in project JMRI by JMRI.
the class LayoutSlip method editLayoutSlip.
/**
* Edit a Slip
*/
protected void editLayoutSlip(LayoutTurnout o) {
if (editOpen) {
editLayoutTurnoutFrame.setVisible(true);
return;
}
// Initialize if needed
if (editLayoutTurnoutFrame == null) {
editLayoutTurnoutFrame = new JmriJFrame(rb.getString("EditSlip"), false, true);
editLayoutTurnoutFrame.addHelpMenu("package.jmri.jmrit.display.EditLayoutSlip", true);
editLayoutTurnoutFrame.setLocation(50, 30);
Container contentPane = editLayoutTurnoutFrame.getContentPane();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
JPanel panel1 = new JPanel();
panel1.setLayout(new FlowLayout());
JLabel turnoutNameLabel = new JLabel(Bundle.getMessage("BeanNameTurnout") + " A " + Bundle.getMessage("Name"));
turnoutAComboBox = new JmriBeanComboBox(InstanceManager.turnoutManagerInstance(), getTurnout(), JmriBeanComboBox.DisplayOptions.DISPLAYNAME);
panel1.add(turnoutNameLabel);
panel1.add(turnoutAComboBox);
contentPane.add(panel1);
JPanel panel1a = new JPanel();
panel1a.setLayout(new FlowLayout());
JLabel turnoutBNameLabel = new JLabel(Bundle.getMessage("BeanNameTurnout") + " B " + Bundle.getMessage("Name"));
turnoutBComboBox = new JmriBeanComboBox(InstanceManager.turnoutManagerInstance(), getTurnoutB(), JmriBeanComboBox.DisplayOptions.DISPLAYNAME);
panel1a.add(turnoutBNameLabel);
panel1a.add(turnoutBComboBox);
contentPane.add(panel1a);
JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayout(0, 3, 2, 2));
panel2.add(new Label(" "));
panel2.add(new Label(Bundle.getMessage("BeanNameTurnout") + " A:"));
panel2.add(new Label(Bundle.getMessage("BeanNameTurnout") + " B:"));
for (Entry<Integer, TurnoutState> ts : turnoutStates.entrySet()) {
SampleStates draw = new SampleStates(ts.getKey());
draw.repaint();
draw.setPreferredSize(new Dimension(40, 40));
panel2.add(draw);
panel2.add(ts.getValue().getComboA());
panel2.add(ts.getValue().getComboB());
}
testPanel = new TestState();
testPanel.setSize(40, 40);
testPanel.setPreferredSize(new Dimension(40, 40));
panel2.add(testPanel);
JButton testButton = new JButton("Test");
testButton.addActionListener((ActionEvent e) -> {
toggleStateTest();
});
panel2.add(testButton);
contentPane.add(panel2);
JPanel panel33 = new JPanel();
panel33.setLayout(new FlowLayout());
hiddenBox.setToolTipText(rb.getString("HiddenToolTip"));
panel33.add(hiddenBox);
contentPane.add(panel33);
// setup block name
JPanel panel3 = new JPanel();
panel3.setLayout(new FlowLayout());
JLabel block1NameLabel = new JLabel(rb.getString("BlockID"));
panel3.add(block1NameLabel);
panel3.add(blockNameComboBox);
layoutEditor.setupComboBox(blockNameComboBox, false, true);
blockNameComboBox.setToolTipText(rb.getString("EditBlockNameHint"));
contentPane.add(panel3);
// set up Edit Block buttons
JPanel panel4 = new JPanel();
panel4.setLayout(new FlowLayout());
// Edit Block
panel4.add(turnoutEditBlock = new JButton(Bundle.getMessage("EditBlock", "")));
turnoutEditBlock.addActionListener((ActionEvent event) -> {
turnoutEditBlockPressed(event);
});
// empty value for block 1
turnoutEditBlock.setToolTipText(Bundle.getMessage("EditBlockHint", ""));
contentPane.add(panel4);
// set up Done and Cancel buttons
JPanel panel5 = new JPanel();
panel5.setLayout(new FlowLayout());
panel5.add(slipEditDone = new JButton(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(slipEditDone);
rootPane.setDefaultButton(slipEditDone);
});
slipEditDone.addActionListener((ActionEvent event) -> {
slipEditDonePressed(event);
});
slipEditDone.setToolTipText(Bundle.getMessage("DoneHint", Bundle.getMessage("ButtonDone")));
// Cancel
panel5.add(slipEditCancel = new JButton(Bundle.getMessage("ButtonCancel")));
slipEditCancel.addActionListener((ActionEvent event) -> {
slipEditCancelPressed(event);
});
slipEditCancel.setToolTipText(Bundle.getMessage("CancelHint", Bundle.getMessage("ButtonCancel")));
contentPane.add(panel5);
}
hiddenBox.setSelected(hidden);
// Set up for Edit
blockNameComboBox.getEditor().setItem(blockName);
editLayoutTurnoutFrame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
slipEditCancelPressed(null);
}
});
editLayoutTurnoutFrame.pack();
editLayoutTurnoutFrame.setVisible(true);
editOpen = true;
needsBlockUpdate = false;
}
Aggregations