1 |
ajm |
1.1 |
import javax.swing.*; |
2 |
|
|
import javax.swing.border.*; |
3 |
|
|
import java.awt.Color; |
4 |
|
|
import uk.ac.ukc.iscream.util.*; |
5 |
|
|
|
6 |
|
|
import java.awt.*; |
7 |
|
|
import java.awt.event.*; |
8 |
|
|
import java.net.*; |
9 |
|
|
import java.io.*; |
10 |
|
|
import java.util.Date; |
11 |
|
|
import java.text.DateFormat; |
12 |
|
|
import java.util.Locale; |
13 |
|
|
import java.util.HashMap; |
14 |
|
|
import javax.swing.border.*; |
15 |
|
|
|
16 |
|
|
public class ControlPanel extends JPanel { |
17 |
|
|
public ControlPanel(DataPanel data) { |
18 |
|
|
super(); |
19 |
|
|
setLayout(new BorderLayout()); |
20 |
|
|
_data = data; |
21 |
|
|
_handler = new ConnectionHandler(_data, _actionQueue); |
22 |
|
|
add(_toolBar, "North"); |
23 |
|
|
_handler.start(); |
24 |
|
|
} |
25 |
|
|
|
26 |
|
|
private JToolBar setupToolBar() { |
27 |
|
|
JButton connectButton = new JButton("Connect"); |
28 |
|
|
connectButton.addActionListener(new ActionListener() { |
29 |
|
|
public void actionPerformed(ActionEvent e) { |
30 |
|
|
_actionQueue.add(new Integer(ConnectionHandler.CONNECT)); |
31 |
|
|
} |
32 |
|
|
}); |
33 |
|
|
|
34 |
ajm |
1.2 |
JButton startDataButton = new JButton("Start Data"); |
35 |
|
|
startDataButton.addActionListener(new ActionListener() { |
36 |
|
|
public void actionPerformed(ActionEvent e) { |
37 |
|
|
_actionQueue.add(new Integer(ConnectionHandler.STARTDATA)); |
38 |
|
|
} |
39 |
|
|
}); |
40 |
|
|
|
41 |
|
|
JButton stopDataButton = new JButton("Stop Data"); |
42 |
|
|
stopDataButton.addActionListener(new ActionListener() { |
43 |
|
|
public void actionPerformed(ActionEvent e) { |
44 |
|
|
_actionQueue.add(new Integer(ConnectionHandler.STOPDATA)); |
45 |
|
|
} |
46 |
|
|
}); |
47 |
|
|
|
48 |
|
|
JButton disconnectButton = new JButton("Disconnect"); |
49 |
|
|
disconnectButton.addActionListener(new ActionListener() { |
50 |
|
|
public void actionPerformed(ActionEvent e) { |
51 |
|
|
_actionQueue.add(new Integer(ConnectionHandler.DISCONNECT)); |
52 |
|
|
} |
53 |
|
|
}); |
54 |
|
|
|
55 |
ajm |
1.1 |
JToolBar bar = new JToolBar(JToolBar.HORIZONTAL); |
56 |
|
|
bar.add(connectButton); |
57 |
ajm |
1.2 |
bar.add(startDataButton); |
58 |
|
|
bar.add(stopDataButton); |
59 |
|
|
bar.add(disconnectButton); |
60 |
ajm |
1.1 |
return bar; |
61 |
|
|
} |
62 |
|
|
|
63 |
|
|
DataPanel _data; |
64 |
|
|
JToolBar _toolBar = setupToolBar(); |
65 |
|
|
|
66 |
|
|
Queue _actionQueue = new Queue(); |
67 |
|
|
ConnectionHandler _handler; |
68 |
|
|
} |