Skip to content

Commit 99006fc

Browse files
MichalSycmaglie
authored andcommitted
Serial Monitor: added "clear output" button
1 parent bd2f4ac commit 99006fc

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

app/src/processing/app/AbstractTextMonitor.java

+8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public abstract class AbstractTextMonitor extends AbstractMonitor {
3434
protected JScrollPane scrollPane;
3535
protected JTextField textField;
3636
protected JButton sendButton;
37+
protected JButton clearButton;
3738
protected JCheckBox autoscrollBox;
3839
protected JComboBox lineEndings;
3940
protected JComboBox serialRates;
@@ -76,6 +77,7 @@ public void windowGainedFocus(WindowEvent e) {
7677
});
7778

7879
sendButton = new JButton(tr("Send"));
80+
clearButton = new JButton(tr("Clear output"));
7981

8082
upperPane.add(textField);
8183
upperPane.add(Box.createRigidArea(new Dimension(4, 0)));
@@ -116,6 +118,7 @@ public void actionPerformed(ActionEvent event) {
116118
serialRates.setMaximumSize(serialRates.getMinimumSize());
117119

118120
pane.add(autoscrollBox);
121+
pane.add(clearButton);
119122
pane.add(Box.createHorizontalGlue());
120123
pane.add(noLineEndingAlert);
121124
pane.add(Box.createRigidArea(new Dimension(8, 0)));
@@ -129,6 +132,7 @@ public void actionPerformed(ActionEvent event) {
129132
protected void onEnableWindow(boolean enable)
130133
{
131134
textArea.setEnabled(enable);
135+
clearButton.setEnabled(enable);
132136
scrollPane.setEnabled(enable);
133137
textField.setEnabled(enable);
134138
sendButton.setEnabled(enable);
@@ -141,6 +145,10 @@ public void onSendCommand(ActionListener listener) {
141145
textField.addActionListener(listener);
142146
sendButton.addActionListener(listener);
143147
}
148+
149+
public void onClearCommand(ActionListener listener) {
150+
clearButton.addActionListener(listener);
151+
}
144152

145153
public void onSerialRateChange(ActionListener listener) {
146154
serialRates.addActionListener(listener);

app/src/processing/app/SerialMonitor.java

+6
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ public void actionPerformed(ActionEvent e) {
6262
textField.setText("");
6363
}
6464
});
65+
66+
onClearCommand(new ActionListener() {
67+
public void actionPerformed(ActionEvent e) {
68+
textArea.setText("");
69+
}
70+
});
6571
}
6672

6773
private void send(String s) {

0 commit comments

Comments
 (0)