1 |
mojays |
2 |
package appl.parallel.starter.server; |
2 |
|
|
|
3 |
|
|
import java.awt.BorderLayout; |
4 |
|
|
import javax.swing.JPanel; |
5 |
|
|
import javax.swing.JFrame; |
6 |
|
|
import java.awt.GridBagLayout; |
7 |
|
|
import javax.swing.JTextArea; |
8 |
|
|
import javax.swing.JLabel; |
9 |
|
|
import javax.swing.JButton; |
10 |
|
|
import java.awt.GridBagConstraints; |
11 |
|
|
import java.awt.Dimension; |
12 |
|
|
import javax.swing.JScrollPane; |
13 |
|
|
import javax.swing.BoxLayout; |
14 |
|
|
import java.awt.Insets; |
15 |
|
|
import java.awt.event.ActionEvent; |
16 |
|
|
import java.awt.event.ActionListener; |
17 |
|
|
|
18 |
|
|
import javax.swing.JPopupMenu; |
19 |
|
|
import javax.swing.JMenuItem; |
20 |
|
|
|
21 |
|
|
import schmitzm.swing.event.PopupMenuListener; |
22 |
|
|
import java.awt.FlowLayout; |
23 |
|
|
import java.awt.GridLayout; |
24 |
|
|
import java.awt.CardLayout; |
25 |
|
|
|
26 |
|
|
/** |
27 |
|
|
* This is the GUI for the {@link XuluServerStarter} |
28 |
|
|
* |
29 |
|
|
* @author Dominik Appl |
30 |
|
|
*/ |
31 |
|
|
public class XuluStarterServerGUI extends JFrame { |
32 |
|
|
|
33 |
|
|
private static final long serialVersionUID = 1L; |
34 |
|
|
|
35 |
|
|
private JPanel jContentPane = null; |
36 |
|
|
|
37 |
|
|
private JPanel controlPanel = null; |
38 |
|
|
|
39 |
|
|
JTextArea consoleArea = null; |
40 |
|
|
|
41 |
|
|
JButton button_start = null; |
42 |
|
|
|
43 |
|
|
JButton button_stop = null; |
44 |
|
|
|
45 |
|
|
JButton button_exit = null; |
46 |
|
|
|
47 |
|
|
private JScrollPane jScrollPane = null; |
48 |
|
|
|
49 |
|
|
private JPopupMenu jPopupMenu = null; // @jve:decl-index=0:visual-constraint="615,231" |
50 |
|
|
|
51 |
|
|
private JMenuItem clearText = null; |
52 |
|
|
|
53 |
|
|
private JPanel jPanel = null; |
54 |
|
|
|
55 |
|
|
private JButton button_clear = null; |
56 |
|
|
|
57 |
|
|
/** |
58 |
|
|
* This is the default constructor |
59 |
|
|
*/ |
60 |
|
|
public XuluStarterServerGUI() { |
61 |
|
|
super(); |
62 |
|
|
initialize(); |
63 |
|
|
} |
64 |
|
|
|
65 |
|
|
/** |
66 |
|
|
* This method initializes this |
67 |
|
|
* |
68 |
|
|
* @return void |
69 |
|
|
*/ |
70 |
|
|
private void initialize() { |
71 |
|
|
this.setSize(450, 316); |
72 |
|
|
this.setContentPane(getJContentPane()); |
73 |
|
|
this.setTitle("Xulu Server Starter"); |
74 |
|
|
} |
75 |
|
|
|
76 |
|
|
/** |
77 |
|
|
* This method initializes jContentPane |
78 |
|
|
* |
79 |
|
|
* @return javax.swing.JPanel |
80 |
|
|
*/ |
81 |
|
|
private JPanel getJContentPane() { |
82 |
|
|
if (jContentPane == null) { |
83 |
|
|
GridBagConstraints gridBagConstraints8 = new GridBagConstraints(); |
84 |
|
|
gridBagConstraints8.fill = GridBagConstraints.HORIZONTAL; |
85 |
|
|
GridBagConstraints gridBagConstraints6 = new GridBagConstraints(); |
86 |
|
|
gridBagConstraints6.gridx = 0; |
87 |
|
|
gridBagConstraints6.ipadx = 140; |
88 |
|
|
gridBagConstraints6.gridy = 2; |
89 |
|
|
GridBagConstraints gridBagConstraints5 = new GridBagConstraints(); |
90 |
|
|
gridBagConstraints5.fill = GridBagConstraints.BOTH; |
91 |
|
|
gridBagConstraints5.gridy = 1; |
92 |
|
|
gridBagConstraints5.ipadx = 0; |
93 |
|
|
gridBagConstraints5.ipady = 0; |
94 |
|
|
gridBagConstraints5.weightx = 1.0; |
95 |
|
|
gridBagConstraints5.weighty = 1.0; |
96 |
|
|
gridBagConstraints5.insets = new Insets(0, 5, 0, 5); |
97 |
|
|
gridBagConstraints5.gridx = 0; |
98 |
|
|
GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); |
99 |
|
|
gridBagConstraints3.gridx = 0; |
100 |
|
|
gridBagConstraints3.ipadx = 0; |
101 |
|
|
gridBagConstraints3.ipady = 0; |
102 |
|
|
gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL; |
103 |
|
|
gridBagConstraints3.gridy = 5; |
104 |
|
|
jContentPane = new JPanel(); |
105 |
|
|
jContentPane.setLayout(new GridBagLayout()); |
106 |
|
|
jContentPane.add(getJScrollPane(), gridBagConstraints5); |
107 |
|
|
jContentPane.add(getControlPanel(), gridBagConstraints6); |
108 |
|
|
jContentPane.add(getJPanel(), gridBagConstraints8); |
109 |
|
|
} |
110 |
|
|
return jContentPane; |
111 |
|
|
} |
112 |
|
|
|
113 |
|
|
/** |
114 |
|
|
* This method initializes controlPanel |
115 |
|
|
* |
116 |
|
|
* @return javax.swing.JPanel |
117 |
|
|
*/ |
118 |
|
|
private JPanel getControlPanel() { |
119 |
|
|
if (controlPanel == null) { |
120 |
|
|
GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); |
121 |
|
|
gridBagConstraints11.fill = GridBagConstraints.BOTH; |
122 |
|
|
gridBagConstraints11.gridy = 3; |
123 |
|
|
gridBagConstraints11.weightx = 1.0; |
124 |
|
|
gridBagConstraints11.weighty = 1.0; |
125 |
|
|
gridBagConstraints11.gridx = 0; |
126 |
|
|
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
127 |
|
|
gridBagConstraints2.gridx = 3; |
128 |
|
|
gridBagConstraints2.anchor = GridBagConstraints.EAST; |
129 |
|
|
gridBagConstraints2.gridy = 1; |
130 |
|
|
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
131 |
|
|
gridBagConstraints1.gridx = 2; |
132 |
|
|
gridBagConstraints1.anchor = GridBagConstraints.WEST; |
133 |
|
|
gridBagConstraints1.gridy = 1; |
134 |
|
|
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
135 |
|
|
gridBagConstraints.gridx = 0; |
136 |
|
|
gridBagConstraints.anchor = GridBagConstraints.WEST; |
137 |
|
|
gridBagConstraints.gridy = 1; |
138 |
|
|
controlPanel = new JPanel(); |
139 |
|
|
controlPanel.setLayout(new GridBagLayout()); |
140 |
|
|
controlPanel.add(getButton_start(), gridBagConstraints); |
141 |
|
|
controlPanel.add(getButton_stop(), gridBagConstraints1); |
142 |
|
|
controlPanel.add(getButton_exit(), gridBagConstraints2); |
143 |
|
|
} |
144 |
|
|
return controlPanel; |
145 |
|
|
} |
146 |
|
|
|
147 |
|
|
/** |
148 |
|
|
* This method initializes consoleArea |
149 |
|
|
* |
150 |
|
|
* @return javax.swing.JTextArea |
151 |
|
|
*/ |
152 |
|
|
private JTextArea getConsoleArea() { |
153 |
|
|
if (consoleArea == null) { |
154 |
|
|
consoleArea = new JTextArea(); |
155 |
|
|
consoleArea.setToolTipText(""); |
156 |
|
|
consoleArea.setWrapStyleWord(false); |
157 |
|
|
consoleArea.setLineWrap(true); |
158 |
|
|
consoleArea.addMouseListener(new PopupMenuListener(this.getJPopupMenu())); |
159 |
|
|
} |
160 |
|
|
return consoleArea; |
161 |
|
|
} |
162 |
|
|
|
163 |
|
|
/** |
164 |
|
|
* This method initializes button_start |
165 |
|
|
* |
166 |
|
|
* @return javax.swing.JButton |
167 |
|
|
*/ |
168 |
|
|
private JButton getButton_start() { |
169 |
|
|
if (button_start == null) { |
170 |
|
|
button_start = new JButton(); |
171 |
|
|
button_start.setText("Start Server"); |
172 |
|
|
} |
173 |
|
|
return button_start; |
174 |
|
|
} |
175 |
|
|
|
176 |
|
|
/** |
177 |
|
|
* This method initializes button_stop |
178 |
|
|
* |
179 |
|
|
* @return javax.swing.JButton |
180 |
|
|
*/ |
181 |
|
|
private JButton getButton_stop() { |
182 |
|
|
if (button_stop == null) { |
183 |
|
|
button_stop = new JButton(); |
184 |
|
|
button_stop.setText("Stop Server"); |
185 |
|
|
} |
186 |
|
|
return button_stop; |
187 |
|
|
} |
188 |
|
|
|
189 |
|
|
/** |
190 |
|
|
* This method initializes button_exit |
191 |
|
|
* |
192 |
|
|
* @return javax.swing.JButton |
193 |
|
|
*/ |
194 |
|
|
private JButton getButton_exit() { |
195 |
|
|
if (button_exit == null) { |
196 |
|
|
button_exit = new JButton(); |
197 |
|
|
button_exit.setText("Exit Starter"); |
198 |
|
|
} |
199 |
|
|
return button_exit; |
200 |
|
|
} |
201 |
|
|
|
202 |
|
|
/** |
203 |
|
|
* This method initializes jScrollPane |
204 |
|
|
* |
205 |
|
|
* @return javax.swing.JScrollPane |
206 |
|
|
*/ |
207 |
|
|
private JScrollPane getJScrollPane() { |
208 |
|
|
if (jScrollPane == null) { |
209 |
|
|
jScrollPane = new JScrollPane(); |
210 |
|
|
jScrollPane.setDoubleBuffered(false); |
211 |
|
|
jScrollPane.setViewportView(getConsoleArea()); |
212 |
|
|
} |
213 |
|
|
return jScrollPane; |
214 |
|
|
} |
215 |
|
|
|
216 |
|
|
/** |
217 |
|
|
* This method initializes jPopupMenu |
218 |
|
|
* |
219 |
|
|
* @return javax.swing.JPopupMenu |
220 |
|
|
*/ |
221 |
|
|
private JPopupMenu getJPopupMenu() { |
222 |
|
|
if (jPopupMenu == null) { |
223 |
|
|
jPopupMenu = new JPopupMenu(); |
224 |
|
|
jPopupMenu.add(getClearText()); |
225 |
|
|
|
226 |
|
|
|
227 |
|
|
} |
228 |
|
|
return jPopupMenu; |
229 |
|
|
} |
230 |
|
|
|
231 |
|
|
/** |
232 |
|
|
* This method initializes clearText |
233 |
|
|
* |
234 |
|
|
* @return javax.swing.JMenuItem |
235 |
|
|
*/ |
236 |
|
|
private JMenuItem getClearText() { |
237 |
|
|
if (clearText == null) { |
238 |
|
|
clearText = new JMenuItem(); |
239 |
|
|
clearText.setText("clear"); |
240 |
|
|
clearText.addActionListener(new java.awt.event.ActionListener() { |
241 |
|
|
public void actionPerformed(java.awt.event.ActionEvent e) { |
242 |
|
|
getConsoleArea().setText(""); |
243 |
|
|
} |
244 |
|
|
}); |
245 |
|
|
} |
246 |
|
|
return clearText; |
247 |
|
|
} |
248 |
|
|
|
249 |
|
|
/** |
250 |
|
|
* This method initializes jPanel |
251 |
|
|
* |
252 |
|
|
* @return javax.swing.JPanel |
253 |
|
|
*/ |
254 |
|
|
private JPanel getJPanel() { |
255 |
|
|
if (jPanel == null) { |
256 |
|
|
FlowLayout flowLayout = new FlowLayout(); |
257 |
|
|
flowLayout.setHgap(0); |
258 |
|
|
flowLayout.setVgap(0); |
259 |
|
|
GridBagConstraints gridBagConstraints9 = new GridBagConstraints(); |
260 |
|
|
gridBagConstraints9.gridx = 0; |
261 |
|
|
gridBagConstraints9.anchor = GridBagConstraints.EAST; |
262 |
|
|
gridBagConstraints9.gridy = 0; |
263 |
|
|
GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); |
264 |
|
|
gridBagConstraints4.gridy = -1; |
265 |
|
|
gridBagConstraints4.anchor = GridBagConstraints.WEST; |
266 |
|
|
gridBagConstraints4.gridx = -1; |
267 |
|
|
jPanel = new JPanel(); |
268 |
|
|
jPanel.setLayout(flowLayout); |
269 |
|
|
jPanel.add(getButton_clear(), null); |
270 |
|
|
} |
271 |
|
|
return jPanel; |
272 |
|
|
} |
273 |
|
|
|
274 |
|
|
/** |
275 |
|
|
* This method initializes button_clear |
276 |
|
|
* |
277 |
|
|
* @return javax.swing.JButton |
278 |
|
|
*/ |
279 |
|
|
private JButton getButton_clear() { |
280 |
|
|
if (button_clear == null) { |
281 |
|
|
button_clear = new JButton(); |
282 |
|
|
button_clear.setText("Clear Console"); |
283 |
|
|
button_clear.setPreferredSize(new Dimension(130, 15)); |
284 |
|
|
button_clear.setName("jButton"); |
285 |
|
|
button_clear.addActionListener(new java.awt.event.ActionListener() { |
286 |
|
|
public void actionPerformed(java.awt.event.ActionEvent e) { |
287 |
|
|
getConsoleArea().setText(""); |
288 |
|
|
} |
289 |
|
|
}); |
290 |
|
|
} |
291 |
|
|
return button_clear; |
292 |
|
|
} |
293 |
|
|
|
294 |
|
|
} // @jve:decl-index=0:visual-constraint="10,10" |