1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 package org.sat4j.sat;
31
32 import java.awt.Dimension;
33 import java.awt.event.ActionEvent;
34 import java.awt.event.ActionListener;
35
36 import javax.swing.BoxLayout;
37 import javax.swing.JButton;
38 import javax.swing.JPanel;
39 import javax.swing.JScrollPane;
40 import javax.swing.JTextArea;
41
42
43
44
45
46
47
48
49
50 public class VerySimpleCommandPanel extends JPanel {
51
52 private static final long serialVersionUID = 1L;
53
54 private RemoteControlStrategy telecomStrategy;
55
56 public final static String RESTART = "Restart";
57 public final static String CLEAN = "Clean";
58
59 private JButton restartButton;
60 private JButton cleanButton;
61
62 private JTextArea console;
63
64 public VerySimpleCommandPanel(RemoteControlStrategy telecomStrategy) {
65 super();
66
67 this.setPreferredSize(new Dimension(200, 200));
68
69 this.telecomStrategy = telecomStrategy;
70
71 this.restartButton = new JButton(RESTART);
72
73 this.restartButton.addActionListener(new ActionListener() {
74 public void actionPerformed(ActionEvent e) {
75 hasClickedOnRestart();
76 }
77 });
78
79 this.cleanButton = new JButton(CLEAN);
80
81 this.cleanButton.addActionListener(new ActionListener() {
82 public void actionPerformed(ActionEvent e) {
83 hasClickedOnClean();
84 }
85 });
86
87 this.console = new JTextArea();
88
89 JScrollPane scrollPane = new JScrollPane(this.console);
90
91
92 scrollPane.setPreferredSize(new Dimension(100, 100));
93
94 this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
95 this.add(this.restartButton);
96 this.add(this.cleanButton);
97 this.add(scrollPane);
98
99 }
100
101 public void hasClickedOnRestart() {
102 this.telecomStrategy.setHasClickedOnRestart(true);
103 this.console.append("Has clicked on " + RESTART + "\n");
104 this.console.repaint();
105 this.repaint();
106 }
107
108 public void hasClickedOnClean() {
109 this.telecomStrategy.setHasClickedOnClean(true);
110 this.console.append("Has clicked on " + CLEAN + "\n");
111 this.console.repaint();
112 this.repaint();
113 }
114
115
116
117
118
119
120
121 }