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.6
Committed: Mon Feb 5 00:52:03 2001 UTC (23 years, 4 months ago) by ajm
Branch: MAIN
Changes since 1.5: +10 -7 lines
Log Message:
now uses some crude icons....

and...back by popular demand, the i-scream logo! HURRAY!

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.5 2001/01/24 03:09:46 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.5 $";
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", 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", 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", 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", 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", 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));
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 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
102 //---ACCESSOR/MUTATOR METHODS---
103
104 //---ATTRIBUTES---
105
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---
122
123 }