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