1 |
|
//---PACKAGE DECLARATION--- |
2 |
+ |
package uk.ac.ukc.iscream.conient; |
3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
|
import uk.ac.ukc.iscream.util.*; |
11 |
|
* This panel holds the toolbar at the top. |
12 |
|
* The tool bar dispatches events to the ConnectionHandler. |
13 |
|
* |
14 |
+ |
* It also creates and starts the ConnectionHandler which is the |
15 |
+ |
* main thread for this application |
16 |
+ |
* |
17 |
|
* @author $Author$ |
18 |
|
* @version $Id$ |
19 |
|
*/ |
30 |
|
|
31 |
|
//---CONSTRUCTORS--- |
32 |
|
|
33 |
+ |
/** |
34 |
+ |
* Constructs a new ControlPanel. |
35 |
+ |
* |
36 |
+ |
* @param data the data panel to be passed to the ConnectionHandler |
37 |
+ |
*/ |
38 |
|
public ControlPanel(DataPanel data) { |
39 |
|
super(); |
40 |
|
setLayout(new BorderLayout()); |
41 |
< |
_data = data; |
33 |
< |
_handler = new ConnectionHandler(_data, _actionQueue); |
41 |
> |
_handler = new ConnectionHandler(data, _actionQueue); |
42 |
|
add(_toolBar, "North"); |
43 |
|
_handler.start(); |
44 |
|
} |
47 |
|
|
48 |
|
//---PRIVATE METHODS--- |
49 |
|
|
50 |
+ |
/** |
51 |
+ |
* Sets up the tool bar, adding action listeners |
52 |
+ |
* to dispatch events to the ConnectionHandler |
53 |
+ |
*/ |
54 |
|
private JToolBar setupToolBar() { |
55 |
< |
JButton connectButton = new JButton("Connect"); |
55 |
> |
JButton connectButton = new JButton("Connect", new ImageIcon("./uk/ac/ukc/iscream/conient/control16.gif")); |
56 |
|
connectButton.addActionListener(new ActionListener() { |
57 |
|
public void actionPerformed(ActionEvent e) { |
58 |
|
_actionQueue.add(new Integer(ConnectionHandler.CONNECT)); |
59 |
|
} |
60 |
|
}); |
61 |
|
|
62 |
< |
JButton startDataButton = new JButton("Start Data"); |
62 |
> |
JButton startDataButton = new JButton("Start Data", new ImageIcon("./uk/ac/ukc/iscream/conient/data16.gif")); |
63 |
|
startDataButton.addActionListener(new ActionListener() { |
64 |
|
public void actionPerformed(ActionEvent e) { |
65 |
|
_actionQueue.add(new Integer(ConnectionHandler.STARTDATA)); |
66 |
|
} |
67 |
|
}); |
68 |
|
|
69 |
< |
JButton stopDataButton = new JButton("Stop Data"); |
69 |
> |
JButton stopDataButton = new JButton("Stop Data", new ImageIcon("./uk/ac/ukc/iscream/conient/stop16.gif")); |
70 |
|
stopDataButton.addActionListener(new ActionListener() { |
71 |
|
public void actionPerformed(ActionEvent e) { |
72 |
|
_actionQueue.add(new Integer(ConnectionHandler.STOPDATA)); |
73 |
|
} |
74 |
|
}); |
75 |
|
|
76 |
< |
JButton disconnectButton = new JButton("Disconnect"); |
76 |
> |
JButton disconnectButton = new JButton("Disconnect", new ImageIcon("./uk/ac/ukc/iscream/conient/stop16.gif")); |
77 |
|
disconnectButton.addActionListener(new ActionListener() { |
78 |
|
public void actionPerformed(ActionEvent e) { |
79 |
|
_actionQueue.add(new Integer(ConnectionHandler.DISCONNECT)); |
80 |
|
} |
81 |
|
}); |
82 |
|
|
83 |
< |
JButton quitButton = new JButton("Quit"); |
83 |
> |
JButton quitButton = new JButton("Quit", new ImageIcon("./uk/ac/ukc/iscream/conient/stop16.gif")); |
84 |
|
quitButton.addActionListener(new ActionListener() { |
85 |
|
public void actionPerformed(ActionEvent e) { |
86 |
|
_actionQueue.add(new Integer(ConnectionHandler.QUIT)); |
93 |
|
bar.add(stopDataButton); |
94 |
|
bar.add(disconnectButton); |
95 |
|
bar.add(quitButton); |
96 |
+ |
bar.add(Box.createGlue()); |
97 |
+ |
JLabel image = new JLabel(new ImageIcon("./uk/ac/ukc/iscream/conient/i-scream.gif")); |
98 |
+ |
bar.add(image); |
99 |
|
return bar; |
100 |
|
} |
101 |
|
|
103 |
|
|
104 |
|
//---ATTRIBUTES--- |
105 |
|
|
106 |
< |
DataPanel _data; |
106 |
> |
/** |
107 |
> |
* The tool bar for the control panel |
108 |
> |
*/ |
109 |
|
JToolBar _toolBar = setupToolBar(); |
110 |
|
|
111 |
+ |
/** |
112 |
+ |
* The queue that we will add actions to. |
113 |
+ |
*/ |
114 |
|
Queue _actionQueue = new Queue(); |
115 |
+ |
|
116 |
+ |
/** |
117 |
+ |
* The connection handler in use by the system. |
118 |
+ |
*/ |
119 |
|
ConnectionHandler _handler; |
120 |
|
|
121 |
|
//---STATIC ATTRIBUTES--- |