Skip to content

Commit 3cbe558

Browse files
chromhelmWilhelm Wiens
authored and
Wilhelm Wiens
committed
Add clear button to SerialPlotter
1 parent 156d5d8 commit 3cbe558

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

app/src/processing/app/SerialPlotter.java

+8
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class SerialPlotter extends AbstractMonitor {
4141

4242
private final StringBuffer messageBuffer;
4343
private JComboBox<String> serialRates;
44+
private JButton clearButton;
4445
private Serial serial;
4546
private int serialRate, xCount;
4647

@@ -255,6 +256,8 @@ public SerialPlotter(BoardPort port) {
255256

256257
messageBuffer = new StringBuffer();
257258
graphs = new ArrayList<>();
259+
260+
clearButton.addActionListener(ae -> {graphs.clear();});
258261
}
259262

260263
protected void onCreateWindow(Container mainPane) {
@@ -273,9 +276,12 @@ protected void onCreateWindow(Container mainPane) {
273276

274277
serialRates.setMaximumSize(serialRates.getMinimumSize());
275278

279+
clearButton = new JButton(tr("Clear output"));
280+
276281
pane.add(Box.createHorizontalGlue());
277282
pane.add(Box.createRigidArea(new Dimension(8, 0)));
278283
pane.add(serialRates);
284+
pane.add(clearButton);
279285

280286
mainPane.add(pane, BorderLayout.SOUTH);
281287

@@ -383,6 +389,8 @@ public void appyPreferences() {
383389
protected void onEnableWindow(boolean enable) {
384390
textField.setEnabled(enable);
385391
sendButton.setEnabled(enable);
392+
serialRates.setEnabled(enable);
393+
clearButton.setEnabled(enable);
386394
}
387395

388396
private void onSerialRateChange(ActionListener listener) {

0 commit comments

Comments
 (0)