ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/conient/uk/org/iscream/cms/conient/ControlPanel.java
Revision: 1.5
Committed: Wed Jan 24 03:09:46 2001 UTC (23 years, 3 months ago) by ajm
Branch: MAIN
Changes since 1.4: +25 -4 lines
Log Message:
all packaged up
all javadoc'd
still not handling stuff (sockets) right just yet....
but its all in a fit state to be PROPER and continue working and expanding on

File Contents

# Content
1 //---PACKAGE DECLARATION---
2 package uk.ac.ukc.iscream.conient;
3
4 //---IMPORTS---
5 import uk.ac.ukc.iscream.util.*;
6 import javax.swing.*;
7 import java.awt.*;
8 import java.awt.event.*;
9
10 /**
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: ajm4 $
18 * @version $Id: ControlPanel.java,v 1.4 2001/01/22 12:48:38 ajm4 Exp $
19 */
20 public class ControlPanel extends JPanel {
21
22 //---FINAL ATTRIBUTES---
23
24 /**
25 * The current CVS revision of this class
26 */
27 public final String REVISION = "$Revision: 1.4 $";
28
29 //---STATIC METHODS---
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 _handler = new ConnectionHandler(data, _actionQueue);
42 add(_toolBar, "North");
43 _handler.start();
44 }
45
46 //---PUBLIC METHODS---
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");
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");
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");
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");
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");
84 quitButton.addActionListener(new ActionListener() {
85 public void actionPerformed(ActionEvent e) {
86 _actionQueue.add(new Integer(ConnectionHandler.QUIT));
87 }
88 });
89
90 JToolBar bar = new JToolBar(JToolBar.HORIZONTAL);
91 bar.add(connectButton);
92 bar.add(startDataButton);
93 bar.add(stopDataButton);
94 bar.add(disconnectButton);
95 bar.add(quitButton);
96 return bar;
97 }
98
99 //---ACCESSOR/MUTATOR METHODS---
100
101 //---ATTRIBUTES---
102
103 /**
104 * The tool bar for the control panel
105 */
106 JToolBar _toolBar = setupToolBar();
107
108 /**
109 * The queue that we will add actions to.
110 */
111 Queue _actionQueue = new Queue();
112
113 /**
114 * The connection handler in use by the system.
115 */
116 ConnectionHandler _handler;
117
118 //---STATIC ATTRIBUTES---
119
120 }