1
2
3
4
5
6 package io.github.olyutorskii.quetexj;
7
8 import java.awt.event.ActionEvent;
9 import java.util.Objects;
10 import javax.swing.AbstractAction;
11 import javax.swing.text.BadLocationException;
12 import javax.swing.text.Document;
13
14
15
16
17 @SuppressWarnings("serial")
18 class ClearDocumentAction extends AbstractAction {
19
20 private final Document document;
21
22
23
24
25
26
27
28 ClearDocumentAction(Document document) {
29 super();
30
31 Objects.requireNonNull(document);
32 this.document = document;
33
34 return;
35 }
36
37
38
39
40 private void eventClearDocument() {
41 int len = this.document.getLength();
42 try {
43 this.document.remove(0, len);
44 } catch (BadLocationException e) {
45 assert false;
46 }
47
48 return;
49 }
50
51
52
53
54
55
56 @Override
57 public void actionPerformed(ActionEvent ev) {
58
59 eventClearDocument();
60 return;
61 }
62
63 }