use of javax.swing.JSeparator in project JMRI by JMRI.
the class PreferencesPane method throttleTab.
private JPanel throttleTab() {
throttletabpanel.setLayout(new BoxLayout(throttletabpanel, BoxLayout.Y_AXIS));
JLabel _throttleLabel = new JLabel("This option control what happens to a loco on the ECoS Database that has been specifically created to enable a throttle to be used");
_throttleLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
throttletabpanel.add(_throttleLabel);
/*_throttleLabel = new JLabel("specifically created to enable a throttle to be used");
throttletabpanel.add(_throttleLabel);*/
_throttleLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
_adhocLocoEcosAsk = new JRadioButton("Always ask when quiting JMRI");
_adhocLocoEcosLeave = new JRadioButton("Always leave the Loco in the Ecos Database");
_adhocLocoEcosRemove = new JRadioButton("Always remove the Loco from the Ecos Database");
switch(ep.getAdhocLocoFromEcos()) {
case 0:
_adhocLocoEcosAsk.setSelected(true);
break;
case 1:
_adhocLocoEcosLeave.setSelected(true);
break;
case 2:
_adhocLocoEcosRemove.setSelected(true);
break;
default:
_adhocLocoEcosAsk.setSelected(true);
break;
}
_adhocLocoEcos = new ButtonGroup();
_adhocLocoEcos.add(_adhocLocoEcosAsk);
_adhocLocoEcos.add(_adhocLocoEcosLeave);
_adhocLocoEcos.add(_adhocLocoEcosRemove);
JPanel adhocEcosGroup = new JPanel();
adhocEcosGroup.setLayout(new BoxLayout(adhocEcosGroup, BoxLayout.Y_AXIS));
adhocEcosGroup.add(_adhocLocoEcosAsk);
adhocEcosGroup.add(_adhocLocoEcosLeave);
adhocEcosGroup.add(_adhocLocoEcosRemove);
adhocEcosGroup.setAlignmentX(Component.CENTER_ALIGNMENT);
throttletabpanel.add(adhocEcosGroup);
/*throttletabpanel.add(_adhocLocoEcosAsk);
throttletabpanel.add(_adhocLocoEcosLeave);
throttletabpanel.add(_adhocLocoEcosRemove);*/
throttletabpanel.add(new JSeparator(SwingConstants.HORIZONTAL));
_throttleLabel = new JLabel("If JMRI can not get control of a loco, this sets how JMRI should react.");
_throttleLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
throttletabpanel.add(_throttleLabel);
_forceControlLocoEcosAsk = new JRadioButton("Always ask when attempting to take control of a loco");
_forceControlLocoEcosNever = new JRadioButton("Never force control of a Loco");
_forceControlLocoEcosAlways = new JRadioButton("Always force control of a Loco");
switch(ep.getForceControlFromEcos()) {
case 0x00:
_forceControlLocoEcosAsk.setSelected(true);
break;
case 0x01:
_forceControlLocoEcosNever.setSelected(true);
break;
case 0x02:
_forceControlLocoEcosAlways.setSelected(true);
break;
default:
_forceControlLocoEcosAsk.setSelected(true);
break;
}
_locoEcosControl = new ButtonGroup();
_locoEcosControl.add(_forceControlLocoEcosAsk);
_locoEcosControl.add(_forceControlLocoEcosNever);
_locoEcosControl.add(_forceControlLocoEcosAlways);
JPanel locoEcosControlGroup = new JPanel();
locoEcosControlGroup.setLayout(new BoxLayout(locoEcosControlGroup, BoxLayout.Y_AXIS));
locoEcosControlGroup.add(_forceControlLocoEcosAsk);
locoEcosControlGroup.add(_forceControlLocoEcosNever);
locoEcosControlGroup.add(_forceControlLocoEcosAlways);
locoEcosControlGroup.setAlignmentX(Component.CENTER_ALIGNMENT);
throttletabpanel.add(locoEcosControlGroup);
/*throttletabpanel.add(new JSeparator(SwingConstants.HORIZONTAL));
JPanel _defaultprotocolpanel = new JPanel();
JLabel _defaultprotocolLabel = new JLabel("Sets the Default protocol to use for an Adhoc Loco");
_defaultprotocolpanel.add(_defaultprotocolLabel);
_defaultProtocol = new JComboBox<String>();
initializeEcosProtocolCombo(_defaultProtocol);
if (ep.getLocoMaster()!=0x00)
setEcosProtocolType(_defaultProtocol, ep.getDefaultEcosProtocol());
defaultprotocolpanel.add(_defaultProtocol);
throttletabpanel.add(_defaultprotocolpanel);*/
throttletabpanel.add(new JSeparator(SwingConstants.HORIZONTAL));
_locoControl = new ButtonGroup();
_locoControlNormal = new JRadioButton("Always gracefully gain control");
_locoControlForce = new JRadioButton("Always force loco control");
_locoControl.add(_locoControlNormal);
_locoControl.add(_locoControlForce);
if (ep.getLocoControl()) {
_locoControlForce.setSelected(true);
} else {
_locoControlNormal.setSelected(true);
}
JLabel _locoControlLabel = new JLabel("How should JMRI attempt to take contol of a loco?");
JPanel locoControlGroup = new JPanel();
locoControlGroup.add(_locoControlLabel);
locoControlGroup.setLayout(new BoxLayout(locoControlGroup, BoxLayout.Y_AXIS));
locoControlGroup.add(_locoControlNormal);
locoControlGroup.add(_locoControlForce);
locoControlGroup.setAlignmentX(Component.CENTER_ALIGNMENT);
throttletabpanel.add(locoControlGroup);
return throttletabpanel;
}
use of javax.swing.JSeparator in project JMRI by JMRI.
the class LocoGenPanel method initComponents.
@Override
public void initComponents() throws Exception {
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
// handle single-packet part
add(new JLabel("Send one packet:"));
{
JPanel pane1 = new JPanel();
pane1.setLayout(new BoxLayout(pane1, BoxLayout.Y_AXIS));
jLabel1.setText("Packet:");
jLabel1.setVisible(true);
sendButton.setText("Send");
sendButton.setVisible(true);
sendButton.setToolTipText("Send packet");
packetTextField.setToolTipText("Enter packet as hex pairs, e.g. 82 7D; checksum should be present but is recalculated");
pane1.add(jLabel1);
pane1.add(packetTextField);
pane1.add(sendButton);
pane1.add(Box.createVerticalGlue());
sendButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
sendButtonActionPerformed(e);
}
});
add(pane1);
}
add(new JSeparator());
// Configure the sequence
add(new JLabel("Send sequence of packets:"));
JPanel pane2 = new JPanel();
pane2.setLayout(new GridLayout(MAXSEQUENCE + 2, 4));
pane2.add(new JLabel(""));
pane2.add(new JLabel("Send"));
pane2.add(new JLabel("packet"));
pane2.add(new JLabel("wait (msec)"));
for (int i = 0; i < MAXSEQUENCE; i++) {
pane2.add(new JLabel(Integer.toString(i + 1)));
mUseField[i] = new JCheckBox();
mPacketField[i] = new JTextField(10);
mDelayField[i] = new JTextField(10);
pane2.add(mUseField[i]);
pane2.add(mPacketField[i]);
pane2.add(mDelayField[i]);
}
// starts a new row in layout
pane2.add(mRunButton);
add(pane2);
mRunButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
runButtonActionPerformed(e);
}
});
}
use of javax.swing.JSeparator in project JMRI by JMRI.
the class SerialPacketGenFrame method initComponents.
@Override
public void initComponents() throws Exception {
// the following code sets the frame's initial state
jLabel1.setText("Command:");
jLabel1.setVisible(true);
sendButton.setText("Send");
sendButton.setVisible(true);
sendButton.setToolTipText("Send packet");
packetTextField.setText("");
packetTextField.setToolTipText("Enter command as hexadecimal bytes separated by a space");
packetTextField.setMaximumSize(new Dimension(packetTextField.getMaximumSize().width, packetTextField.getPreferredSize().height));
setTitle("Send Maple serial command");
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
getContentPane().add(jLabel1);
getContentPane().add(packetTextField);
getContentPane().add(sendButton);
sendButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
sendButtonActionPerformed(e);
}
});
getContentPane().add(new JSeparator(JSeparator.HORIZONTAL));
// add poll message buttons
JPanel pane3 = new JPanel();
pane3.setLayout(new FlowLayout());
pane3.add(new JLabel("UA:"));
pane3.add(uaAddrField);
pane3.add(pollButton);
uaAddrField.setText("0");
uaAddrField.setToolTipText("Enter node address (decimal integer)");
getContentPane().add(pane3);
pollButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
pollButtonActionPerformed(e);
}
});
pollButton.setToolTipText("Send poll request (first command only, if multiple commands)");
// pack for display
pack();
}
use of javax.swing.JSeparator in project JMRI by JMRI.
the class NcePacketMonitorPanel method initComponents.
@Override
public void initComponents(NceSystemConnectionMemo m) throws Exception {
this.memo = m;
// populate the GUI, invoked as part of startup
// load the port selection part
portBox.setToolTipText("Select the port to use");
portBox.setAlignmentX(JLabel.LEFT_ALIGNMENT);
Vector<String> v = getPortNames();
for (int i = 0; i < v.size(); i++) {
portBox.addItem(v.elementAt(i));
}
openPortButton.setText("Open");
openPortButton.setToolTipText("Configure program to use selected port");
openPortButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
try {
openPortButtonActionPerformed(evt);
//} catch (jmri.jmrix.SerialConfigException ex) {
// log.error("Error while opening port. Did you select the right one?\n"+ex);
} catch (java.lang.UnsatisfiedLinkError ex) {
log.error("Error while opening port. Did you select the right one?\n" + ex);
}
}
});
{
JSeparator js = new JSeparator();
js.setMaximumSize(new Dimension(10000, 10));
add(js);
}
JPanel p1 = new JPanel();
p1.setLayout(new FlowLayout());
p1.add(new JLabel("Serial port: "));
p1.add(portBox);
p1.add(openPortButton);
p1.setMaximumSize(p1.getPreferredSize());
add(p1);
// add user part of GUI
{
JSeparator js = new JSeparator();
js.setMaximumSize(new Dimension(10000, 10));
add(js);
}
JPanel p2 = new JPanel();
{
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
checkButton.setToolTipText("?");
checkButton.setEnabled(false);
p.add(checkButton);
checkButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (checkButton.isSelected()) {
sendBytes(new byte[] { (byte) '?' });
checkButton.setText("Res.");
checkButton.setToolTipText("Resume packet monitoring");
} else {
sendBytes(new byte[] { (byte) ' ' });
checkButton.setText("Info");
checkButton.setToolTipText("?");
}
}
});
truncateCheckBox.setToolTipText("Check this box to suppress identical packets");
p.add(truncateCheckBox);
p2.add(p);
}
{
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
ButtonGroup g = new ButtonGroup();
JRadioButton b;
b = new JRadioButton("Verbose");
b.setToolTipText("V");
g.add(b);
p.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'V' });
}
});
b = new JRadioButton("Hex with preamble symbol");
b.setToolTipText("H0");
g.add(b);
p.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'H', (byte) '0' });
}
});
p2.add(p);
b = new JRadioButton("(as above with spaces)");
b.setToolTipText("H1");
g.add(b);
p.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'H', (byte) '1' });
}
});
p2.add(p);
b = new JRadioButton("Hex without preamble symbol");
b.setToolTipText("H2");
g.add(b);
p.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'H', (byte) '2' });
}
});
p2.add(p);
b = new JRadioButton("(as above with spaces)");
b.setToolTipText("H3");
g.add(b);
p.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'H', (byte) '3' });
}
});
p2.add(p);
b = new JRadioButton("Hex with preamble count in hex");
b.setToolTipText("H4");
g.add(b);
p.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'H', (byte) '4' });
}
});
p2.add(p);
b = new JRadioButton("(as above with spaces)");
b.setToolTipText("H5");
g.add(b);
p.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'H', (byte) '5' });
}
});
p2.add(p);
}
// end hex/verbose group
{
// start acc off/on
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
ButtonGroup g = new ButtonGroup();
JRadioButton b;
b = new JRadioButton("Hide acc packets");
b.setToolTipText("A-");
g.add(b);
p.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'A', (byte) '-' });
}
});
b = new JRadioButton("Show acc packets");
b.setToolTipText("A+");
g.add(b);
p.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'A', (byte) '+' });
}
});
p2.add(p);
}
// end acc off/on
{
// start idle off/on
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
ButtonGroup g = new ButtonGroup();
JRadioButton b;
b = new JRadioButton("Hide idle packets");
b.setToolTipText("I-");
g.add(b);
p.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'I', (byte) '-' });
}
});
b = new JRadioButton("Show idle packets");
b.setToolTipText("I+");
g.add(b);
p.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'I', (byte) '+' });
}
});
p2.add(p);
}
// end idle off/on
{
// start loco off/on
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
ButtonGroup g = new ButtonGroup();
JRadioButton b;
locoSpeedButton.setToolTipText("L-");
g.add(locoSpeedButton);
p.add(locoSpeedButton);
locoSpeedButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'L', (byte) '-' });
}
});
b = new JRadioButton("Show loco packets");
b.setToolTipText("L+");
g.add(b);
p.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'L', (byte) '+' });
}
});
p2.add(p);
}
// end loco off/on
{
// start reset off/on
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
ButtonGroup g = new ButtonGroup();
JRadioButton b;
b = new JRadioButton("Hide reset packets");
b.setToolTipText("R-");
g.add(b);
p.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'R', (byte) '-' });
}
});
b = new JRadioButton("Show reset packets");
b.setToolTipText("R+");
g.add(b);
p.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'R', (byte) '+' });
}
});
p2.add(p);
}
// end reset off/on
{
// start signal on/off
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
ButtonGroup g = new ButtonGroup();
JRadioButton b;
b = new JRadioButton("Hide signal packets");
b.setToolTipText("S-");
g.add(b);
p.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'S', (byte) '-' });
}
});
b = new JRadioButton("Show signal packets");
b.setToolTipText("S+");
g.add(b);
p.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'S', (byte) '+' });
}
});
p2.add(p);
}
// end signal off/on
{
// Monitor command acc single/double
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
JLabel t = new JLabel("Monitor Command");
p.add(t);
ButtonGroup g = new ButtonGroup();
JRadioButton b;
b = new JRadioButton("Acc addresses single");
b.setToolTipText("AS");
g.add(b);
p.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'A', (byte) 'S' });
}
});
b = new JRadioButton("Acc addresses paired");
b.setToolTipText("AP");
g.add(b);
p.add(b);
b.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendBytes(new byte[] { (byte) 'A', (byte) 'P' });
}
});
p2.add(p);
}
// end acc single/double
p2.setMaximumSize(p2.getPreferredSize());
JScrollPane ps = new JScrollPane(p2);
ps.setMaximumSize(ps.getPreferredSize());
ps.setVisible(true);
add(ps);
}
use of javax.swing.JSeparator in project JMRI by JMRI.
the class SerialPacketGenFrame method initComponents.
@Override
public void initComponents() throws Exception {
// the following code sets the frame's initial state
jLabel1.setText("Command:");
jLabel1.setVisible(true);
sendButton.setText("Send");
sendButton.setVisible(true);
sendButton.setToolTipText("Send packet");
packetTextField.setText("");
packetTextField.setToolTipText("Enter command as hexadecimal bytes separated by a space");
packetTextField.setMaximumSize(new Dimension(packetTextField.getMaximumSize().width, packetTextField.getPreferredSize().height));
setTitle("Send Oak Tree serial command");
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
getContentPane().add(jLabel1);
getContentPane().add(packetTextField);
getContentPane().add(sendButton);
sendButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
sendButtonActionPerformed(e);
}
});
getContentPane().add(new JSeparator(JSeparator.HORIZONTAL));
// add poll message buttons
JPanel pane3 = new JPanel();
pane3.setLayout(new FlowLayout());
pane3.add(new JLabel("Address:"));
pane3.add(uaAddrField);
pane3.add(pollButton);
uaAddrField.setText("0");
uaAddrField.setToolTipText("Enter node address (decimal integer)");
getContentPane().add(pane3);
pollButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
pollButtonActionPerformed(e);
}
});
pollButton.setToolTipText("Send poll request");
// pack for display
pack();
}
Aggregations