2 |
|
package uk.org.iscream.conient; |
3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
< |
import java.awt.Frame; |
6 |
< |
import java.awt.Color; |
7 |
< |
import java.awt.GridLayout; |
5 |
> |
import java.awt.*; |
6 |
|
import java.awt.event.*; |
7 |
|
import javax.swing.*; |
8 |
|
import javax.swing.border.*; |
94 |
|
//---PRIVATE METHODS--- |
95 |
|
|
96 |
|
private JPanel createClientOptions() { |
97 |
+ |
GridBagLayout gridbag = new GridBagLayout(); |
98 |
+ |
GridBagLayout gridbag2 = new GridBagLayout(); |
99 |
+ |
GridBagConstraints c = new GridBagConstraints(); |
100 |
+ |
c.fill = GridBagConstraints.HORIZONTAL; |
101 |
+ |
|
102 |
|
JPanel clientPanel = new JPanel(); |
103 |
< |
clientPanel.setLayout(new BoxLayout(clientPanel, BoxLayout.Y_AXIS)); |
103 |
> |
clientPanel.setLayout(gridbag); |
104 |
|
JLabel nameLabel = new JLabel("Client name:"); |
105 |
|
nameLabel.setHorizontalAlignment(JLabel.RIGHT); |
106 |
|
name = new JTextField(20); |
108 |
|
nameBox.setLayout(new GridLayout(1,2)); |
109 |
|
nameBox.add(nameLabel); |
110 |
|
nameBox.add(name); |
111 |
+ |
|
112 |
+ |
c.gridy = 0; |
113 |
+ |
gridbag.setConstraints(nameBox, c); |
114 |
|
clientPanel.add(nameBox); |
115 |
|
|
116 |
|
JPanel lists = new JPanel(); |
117 |
< |
lists.setLayout(new BoxLayout(lists, BoxLayout.X_AXIS)); |
117 |
> |
lists.setLayout(gridbag2); |
118 |
|
|
119 |
|
JPanel knownHostsPanel = new JPanel(); |
120 |
|
knownHostsPanel.setLayout(new BoxLayout(knownHostsPanel, BoxLayout.Y_AXIS)); |
128 |
|
JLabel newHostLabel = new JLabel("New host:"); |
129 |
|
newHostLabel.setHorizontalAlignment(JLabel.RIGHT); |
130 |
|
newHost = new JTextField(20); |
131 |
< |
JButton newHostButton = new JButton("Add to known hosts"); |
131 |
> |
|
132 |
> |
JButton newHostButton = new JButton("Add Host"); |
133 |
|
newHostButton.addActionListener(new ActionListener() { |
134 |
|
public void actionPerformed(ActionEvent e) { |
135 |
|
knownHostsModel.addElement(newHost.getText()); |
136 |
|
newHost.setText(""); |
137 |
|
} |
138 |
|
}); |
139 |
+ |
JButton removeHostButton = new JButton("Remove Host(s)"); |
140 |
+ |
removeHostButton.addActionListener(new ActionListener() { |
141 |
+ |
public void actionPerformed(ActionEvent e) { |
142 |
+ |
Object[] selected = knownHosts.getSelectedValues(); |
143 |
+ |
for(int x = 0; x < selected.length; x++) { |
144 |
+ |
knownHostsModel.removeElement(selected[x]); |
145 |
+ |
} |
146 |
+ |
} |
147 |
+ |
}); |
148 |
|
JPanel newHostBox = new JPanel(); |
149 |
|
newHostBox.setLayout(new GridLayout(1,3)); |
150 |
|
newHostBox.add(newHostLabel); |
151 |
|
newHostBox.add(newHost); |
152 |
< |
|
152 |
> |
|
153 |
> |
JPanel buttonPanel = new JPanel(); |
154 |
> |
buttonPanel.add(newHostButton); |
155 |
> |
buttonPanel.add(removeHostButton); |
156 |
> |
knownHostsPanel.add(buttonPanel); |
157 |
|
knownHostsPanel.add(newHostBox); |
158 |
< |
knownHostsPanel.add(newHostButton); |
158 |
> |
|
159 |
> |
|
160 |
> |
c.gridy = 0; |
161 |
> |
c.gridx = 0; |
162 |
> |
gridbag.setConstraints(knownHostsPanel, c); |
163 |
|
lists.add(knownHostsPanel); |
164 |
|
|
165 |
|
|
191 |
|
}); |
192 |
|
addRemoveBox.add(remove); |
193 |
|
addRemoveBox.add(Box.createGlue()); |
194 |
+ |
|
195 |
+ |
c.gridy = 0; |
196 |
+ |
c.gridx = 1; |
197 |
+ |
gridbag.setConstraints(addRemoveBox, c); |
198 |
|
lists.add(addRemoveBox); |
199 |
|
|
200 |
|
JPanel hostListPanel = new JPanel(); |
206 |
|
hostList.setVisibleRowCount(10); |
207 |
|
JScrollPane hostListScrollPane = new JScrollPane(hostList); |
208 |
|
hostListPanel.add(hostListScrollPane); |
209 |
+ |
|
210 |
+ |
c.gridy = 0; |
211 |
+ |
c.gridx = 2; |
212 |
+ |
gridbag.setConstraints(hostListPanel, c); |
213 |
|
lists.add(hostListPanel); |
214 |
|
|
215 |
+ |
c.gridy = 1; |
216 |
+ |
c.gridx = 0; |
217 |
+ |
gridbag.setConstraints(lists, c); |
218 |
|
clientPanel.add(lists); |
219 |
|
return clientPanel; |
220 |
|
} |
221 |
|
|
222 |
|
private JPanel createServerOptions() { |
223 |
+ |
GridBagLayout gridbag = new GridBagLayout(); |
224 |
+ |
GridBagConstraints c = new GridBagConstraints(); |
225 |
+ |
c.fill = GridBagConstraints.HORIZONTAL; |
226 |
|
JPanel serverPanel = new JPanel(); |
227 |
< |
serverPanel.setLayout(new BoxLayout(serverPanel, BoxLayout.Y_AXIS)); |
227 |
> |
serverPanel.setLayout(gridbag); |
228 |
|
JLabel serverLabel = new JLabel("i-scream Server:"); |
229 |
|
serverLabel.setHorizontalAlignment(JLabel.RIGHT); |
230 |
|
server = new JTextField(20); |
232 |
|
serverBox.setLayout(new GridLayout(1,2)); |
233 |
|
serverBox.add(serverLabel); |
234 |
|
serverBox.add(server); |
235 |
+ |
c.gridy = 0; |
236 |
+ |
gridbag.setConstraints(serverBox, c); |
237 |
|
serverPanel.add(serverBox); |
198 |
– |
|
238 |
|
JLabel portLabel = new JLabel("Client interface port:"); |
239 |
|
portLabel.setHorizontalAlignment(JLabel.RIGHT); |
240 |
|
port = new JTextField(4); |
242 |
|
portBox.setLayout(new GridLayout(1,2)); |
243 |
|
portBox.add(portLabel); |
244 |
|
portBox.add(port); |
245 |
+ |
c.gridy = 1; |
246 |
+ |
gridbag.setConstraints(portBox, c); |
247 |
|
serverPanel.add(portBox); |
207 |
– |
|
248 |
|
connectControl = new JCheckBox("Automatically connect the control channel"); |
249 |
+ |
c.gridy = 2; |
250 |
+ |
gridbag.setConstraints(connectControl, c); |
251 |
|
serverPanel.add(connectControl); |
252 |
|
connectData = new JCheckBox("Automatically connect the data channel"); |
253 |
+ |
c.gridy = 3; |
254 |
+ |
gridbag.setConstraints(connectData, c); |
255 |
|
serverPanel.add(connectData); |
256 |
|
return serverPanel; |
257 |
|
} |
258 |
|
|
259 |
|
private JPanel createFirewallOptions() { |
260 |
+ |
GridBagLayout gridbag = new GridBagLayout(); |
261 |
+ |
GridBagConstraints c = new GridBagConstraints(); |
262 |
+ |
c.fill = GridBagConstraints.HORIZONTAL; |
263 |
|
JPanel firewallPanel = new JPanel(); |
264 |
< |
firewallPanel.setLayout(new BoxLayout(firewallPanel, BoxLayout.Y_AXIS)); |
264 |
> |
firewallPanel.setLayout(gridbag); |
265 |
> |
|
266 |
|
|
267 |
|
useFirewall = new JCheckBox("Use firewall command to connect through to server"); |
268 |
+ |
c.gridy = 0; |
269 |
+ |
gridbag.setConstraints(useFirewall, c); |
270 |
|
firewallPanel.add(useFirewall); |
271 |
< |
|
271 |
> |
|
272 |
|
JLabel commandLabel = new JLabel("Firewall command:"); |
273 |
|
commandLabel.setHorizontalAlignment(JLabel.RIGHT); |
274 |
|
firewallCommand = new JTextField(20); |
275 |
+ |
firewallCommand.setSize(new Dimension(1,10)); |
276 |
|
JPanel commandBox = new JPanel(); |
277 |
|
commandBox.setLayout(new GridLayout(1,2)); |
278 |
|
commandBox.add(commandLabel); |
279 |
|
commandBox.add(firewallCommand); |
280 |
|
|
281 |
+ |
c.gridy = 1; |
282 |
+ |
gridbag.setConstraints(commandBox, c); |
283 |
|
firewallPanel.add(commandBox); |
284 |
|
|
285 |
|
JLabel waitLabel = new JLabel("Firewall wait time:"); |
289 |
|
waitBox.setLayout(new GridLayout(1,2)); |
290 |
|
waitBox.add(waitLabel); |
291 |
|
waitBox.add(firewallWait); |
292 |
< |
|
292 |
> |
|
293 |
> |
c.gridy = 2; |
294 |
> |
gridbag.setConstraints(waitBox, c); |
295 |
|
firewallPanel.add(waitBox); |
296 |
|
|
297 |
|
JLabel fserverLabel = new JLabel("Firewall server:"); |
302 |
|
fserverBox.add(fserverLabel); |
303 |
|
fserverBox.add(firewallServer); |
304 |
|
|
305 |
+ |
c.gridy = 3; |
306 |
+ |
gridbag.setConstraints(fserverBox, c); |
307 |
|
firewallPanel.add(fserverBox); |
308 |
< |
firewallPanel.add(Box.createGlue()); |
308 |
> |
|
309 |
|
return firewallPanel; |
310 |
|
} |
311 |
|
|
312 |
|
private JPanel createDataOptions() { |
313 |
+ |
GridBagLayout gridbag = new GridBagLayout(); |
314 |
+ |
GridBagConstraints c = new GridBagConstraints(); |
315 |
+ |
c.fill = GridBagConstraints.HORIZONTAL; |
316 |
|
JPanel dataPanel = new JPanel(); |
317 |
< |
dataPanel.setLayout(new BoxLayout(dataPanel, BoxLayout.Y_AXIS)); |
258 |
< |
|
317 |
> |
dataPanel.setLayout(gridbag); |
318 |
|
displayQueue = new JCheckBox("Display server queue information"); |
319 |
+ |
c.gridy = 0; |
320 |
+ |
gridbag.setConstraints(displayQueue, c); |
321 |
|
dataPanel.add(displayQueue); |
322 |
|
displayExtra = new JCheckBox("Display extra data found in packets"); |
323 |
+ |
c.gridy = 1; |
324 |
+ |
gridbag.setConstraints(displayExtra, c); |
325 |
|
dataPanel.add(displayExtra); |
326 |
|
packetDump = new JCheckBox("Dump raw packet data to the console"); |
327 |
+ |
c.gridy = 2; |
328 |
+ |
gridbag.setConstraints(packetDump, c); |
329 |
|
dataPanel.add(packetDump); |
265 |
– |
|
266 |
– |
dataPanel.add(Box.createGlue()); |
330 |
|
return dataPanel; |
331 |
|
} |
332 |
|
|