Skip to content

Commit 219cc6c

Browse files
committed
Add clear button to SerialPlotter
1 parent d89ffe2 commit 219cc6c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

app/src/processing/app/SerialPlotter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class SerialPlotter extends AbstractMonitor {
3737

3838
private final StringBuffer messageBuffer;
3939
private JComboBox<String> serialRates;
40+
private JButton clearButton;
4041
private Serial serial;
4142
private int serialRate, xCount;
4243

@@ -231,6 +232,8 @@ public SerialPlotter(BoardPort port) {
231232

232233
messageBuffer = new StringBuffer();
233234
graphs = new ArrayList<>();
235+
236+
clearButton.addActionListener(ae -> {graphs.clear();});
234237
}
235238

236239
protected void onCreateWindow(Container mainPane) {
@@ -248,16 +251,20 @@ protected void onCreateWindow(Container mainPane) {
248251
for (String serialRateString : serialRateStrings) serialRates.addItem(serialRateString + " " + tr("baud"));
249252

250253
serialRates.setMaximumSize(serialRates.getMinimumSize());
254+
255+
clearButton = new JButton(tr("Clear output"));
251256

252257
pane.add(Box.createHorizontalGlue());
253258
pane.add(Box.createRigidArea(new Dimension(8, 0)));
254259
pane.add(serialRates);
260+
pane.add(clearButton);
255261

256262
mainPane.add(pane, BorderLayout.SOUTH);
257263
}
258264

259265
protected void onEnableWindow(boolean enable) {
260266
serialRates.setEnabled(enable);
267+
clearButton.setEnabled(enable);
261268
}
262269

263270
private void onSerialRateChange(ActionListener listener) {

0 commit comments

Comments
 (0)