Serial Monitor: added "clear output" button

This commit is contained in:
Michael michael.sytko 2017-01-28 10:49:23 +01:00 committed by Cristian Maglie
parent bd2f4acba7
commit 99006fc5c6
2 changed files with 14 additions and 0 deletions

View File

@ -34,6 +34,7 @@ public abstract class AbstractTextMonitor extends AbstractMonitor {
protected JScrollPane scrollPane;
protected JTextField textField;
protected JButton sendButton;
protected JButton clearButton;
protected JCheckBox autoscrollBox;
protected JComboBox lineEndings;
protected JComboBox serialRates;
@ -76,6 +77,7 @@ public abstract class AbstractTextMonitor extends AbstractMonitor {
});
sendButton = new JButton(tr("Send"));
clearButton = new JButton(tr("Clear output"));
upperPane.add(textField);
upperPane.add(Box.createRigidArea(new Dimension(4, 0)));
@ -116,6 +118,7 @@ public abstract class AbstractTextMonitor extends AbstractMonitor {
serialRates.setMaximumSize(serialRates.getMinimumSize());
pane.add(autoscrollBox);
pane.add(clearButton);
pane.add(Box.createHorizontalGlue());
pane.add(noLineEndingAlert);
pane.add(Box.createRigidArea(new Dimension(8, 0)));
@ -129,6 +132,7 @@ public abstract class AbstractTextMonitor extends AbstractMonitor {
protected void onEnableWindow(boolean enable)
{
textArea.setEnabled(enable);
clearButton.setEnabled(enable);
scrollPane.setEnabled(enable);
textField.setEnabled(enable);
sendButton.setEnabled(enable);
@ -141,6 +145,10 @@ public abstract class AbstractTextMonitor extends AbstractMonitor {
textField.addActionListener(listener);
sendButton.addActionListener(listener);
}
public void onClearCommand(ActionListener listener) {
clearButton.addActionListener(listener);
}
public void onSerialRateChange(ActionListener listener) {
serialRates.addActionListener(listener);

View File

@ -62,6 +62,12 @@ public class SerialMonitor extends AbstractTextMonitor {
textField.setText("");
}
});
onClearCommand(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textArea.setText("");
}
});
}
private void send(String s) {