Skip to content

Issue #5849: Added clear button to serial monitor UI #6092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/src/processing/app/AbstractTextMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public abstract class AbstractTextMonitor extends AbstractMonitor {
protected JCheckBox autoscrollBox;
protected JComboBox lineEndings;
protected JComboBox serialRates;
protected JButton clearButton;

public AbstractTextMonitor(BoardPort boardPort) {
super(boardPort);
Expand Down Expand Up @@ -81,6 +82,9 @@ public void windowGainedFocus(WindowEvent e) {
upperPane.add(Box.createRigidArea(new Dimension(4, 0)));
upperPane.add(sendButton);

clearButton = new JButton(tr("Clear"));
upperPane.add(clearButton);

mainPane.add(upperPane, BorderLayout.NORTH);

final JPanel pane = new JPanel();
Expand Down Expand Up @@ -132,6 +136,7 @@ protected void onEnableWindow(boolean enable)
scrollPane.setEnabled(enable);
textField.setEnabled(enable);
sendButton.setEnabled(enable);
clearButton.setEnabled(enable);
autoscrollBox.setEnabled(enable);
lineEndings.setEnabled(enable);
serialRates.setEnabled(enable);
Expand All @@ -141,6 +146,10 @@ public void onSendCommand(ActionListener listener) {
textField.addActionListener(listener);
sendButton.addActionListener(listener);
}

public void onClearCommand(ActionListener listener) {
clearButton.addActionListener(listener);
}

public void onSerialRateChange(ActionListener listener) {
serialRates.addActionListener(listener);
Expand Down
7 changes: 7 additions & 0 deletions app/src/processing/app/SerialMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ public void actionPerformed(ActionEvent e) {
textField.setText("");
}
});

onClearCommand(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textArea.setText("");
}
});

}

private void send(String s) {
Expand Down