mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-15 12:29:26 +01:00
Adding drop-down for selecting line ending to serial monitor (issue #119). Also switching subpanes from BorderLayout to BoxLayout.
This commit is contained in:
parent
03a62f38d2
commit
6f96ce0df2
@ -35,6 +35,7 @@ public class SerialMonitor extends JFrame implements MessageConsumer {
|
|||||||
private JTextField textField;
|
private JTextField textField;
|
||||||
private JButton sendButton;
|
private JButton sendButton;
|
||||||
private JCheckBox autoscrollBox;
|
private JCheckBox autoscrollBox;
|
||||||
|
private JComboBox lineEndings;
|
||||||
private JComboBox serialRates;
|
private JComboBox serialRates;
|
||||||
private int serialRate;
|
private int serialRate;
|
||||||
|
|
||||||
@ -74,7 +75,8 @@ public class SerialMonitor extends JFrame implements MessageConsumer {
|
|||||||
|
|
||||||
getContentPane().add(scrollPane, BorderLayout.CENTER);
|
getContentPane().add(scrollPane, BorderLayout.CENTER);
|
||||||
|
|
||||||
JPanel pane = new JPanel(new BorderLayout(4, 0));
|
JPanel pane = new JPanel();
|
||||||
|
pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS));
|
||||||
pane.setBorder(new EmptyBorder(4, 4, 4, 4));
|
pane.setBorder(new EmptyBorder(4, 4, 4, 4));
|
||||||
|
|
||||||
textField = new JTextField(40);
|
textField = new JTextField(40);
|
||||||
@ -91,16 +93,24 @@ public class SerialMonitor extends JFrame implements MessageConsumer {
|
|||||||
textField.setText("");
|
textField.setText("");
|
||||||
}});
|
}});
|
||||||
|
|
||||||
pane.add(textField, BorderLayout.CENTER);
|
lineEndings = new JComboBox(new String[] { "No line ending", "Newline", "Carriage return", "Both" });
|
||||||
pane.add(sendButton, BorderLayout.EAST);
|
lineEndings.setMaximumSize(lineEndings.getMinimumSize());
|
||||||
|
|
||||||
|
pane.add(textField);
|
||||||
|
pane.add(Box.createRigidArea(new Dimension(4, 0)));
|
||||||
|
pane.add(sendButton);
|
||||||
|
pane.add(Box.createRigidArea(new Dimension(8, 0)));
|
||||||
|
pane.add(lineEndings);
|
||||||
|
|
||||||
getContentPane().add(pane, BorderLayout.NORTH);
|
getContentPane().add(pane, BorderLayout.NORTH);
|
||||||
|
|
||||||
pane = new JPanel(new BorderLayout(4, 0));
|
pane = new JPanel();
|
||||||
|
pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS));
|
||||||
pane.setBorder(new EmptyBorder(4, 4, 4, 4));
|
pane.setBorder(new EmptyBorder(4, 4, 4, 4));
|
||||||
|
|
||||||
autoscrollBox = new JCheckBox("Automatically scroll when new data is received.", true);
|
autoscrollBox = new JCheckBox("Automatically scroll when new data is received.", true);
|
||||||
pane.add(autoscrollBox, BorderLayout.CENTER);
|
pane.add(autoscrollBox);
|
||||||
|
pane.add(Box.createHorizontalGlue());
|
||||||
|
|
||||||
String[] serialRateStrings = {
|
String[] serialRateStrings = {
|
||||||
"300","1200","2400","4800","9600","14400",
|
"300","1200","2400","4800","9600","14400",
|
||||||
@ -127,7 +137,9 @@ public class SerialMonitor extends JFrame implements MessageConsumer {
|
|||||||
}
|
}
|
||||||
}});
|
}});
|
||||||
|
|
||||||
pane.add(serialRates, BorderLayout.EAST);
|
serialRates.setMaximumSize(serialRates.getMinimumSize());
|
||||||
|
|
||||||
|
pane.add(serialRates);
|
||||||
|
|
||||||
getContentPane().add(pane, BorderLayout.SOUTH);
|
getContentPane().add(pane, BorderLayout.SOUTH);
|
||||||
|
|
||||||
@ -135,9 +147,15 @@ public class SerialMonitor extends JFrame implements MessageConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void send(String s) {
|
private void send(String s) {
|
||||||
if (serial != null)
|
if (serial != null) {
|
||||||
|
switch (lineEndings.getSelectedIndex()) {
|
||||||
|
case 1: s += "\n"; break;
|
||||||
|
case 2: s += "\r"; break;
|
||||||
|
case 3: s += "\r\n"; break;
|
||||||
|
}
|
||||||
serial.write(s);
|
serial.write(s);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void openSerialPort() throws SerialException {
|
public void openSerialPort() throws SerialException {
|
||||||
if (serial != null) return;
|
if (serial != null) return;
|
||||||
|
@ -38,6 +38,9 @@ ARDUINO 0019
|
|||||||
* Adding control over scrolling in serial monitor.
|
* Adding control over scrolling in serial monitor.
|
||||||
http://code.google.com/p/arduino/issues/detail?id=97
|
http://code.google.com/p/arduino/issues/detail?id=97
|
||||||
|
|
||||||
|
* Added drop-down for selecting line endings to the serial monitor.
|
||||||
|
http://code.google.com/p/arduino/issues/detail?id=119
|
||||||
|
|
||||||
* Fixed problem with tabs of the same name but different extensions.
|
* Fixed problem with tabs of the same name but different extensions.
|
||||||
http://code.google.com/p/arduino/issues/detail?id=191
|
http://code.google.com/p/arduino/issues/detail?id=191
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user