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.7
Committed: Sun Feb 25 18:00:17 2001 UTC (23 years, 2 months ago) by ajm
Branch: MAIN
Changes since 1.6: +5 -4 lines
Log Message:
Fixed bug which mean it didn't work on ealier jvm

File Contents

# User Rev Content
1 ajm 1.4 //---PACKAGE DECLARATION---
2 ajm 1.5 package uk.ac.ukc.iscream.conient;
3 ajm 1.4
4     //---IMPORTS---
5     import uk.ac.ukc.iscream.util.*;
6 ajm 1.1 import javax.swing.*;
7 ajm 1.7 import java.awt.BorderLayout;
8     import java.awt.event.ActionListener;
9     import java.awt.event.ActionEvent;
10 ajm 1.1
11 ajm 1.4 /**
12     * This panel holds the toolbar at the top.
13     * The tool bar dispatches events to the ConnectionHandler.
14     *
15 ajm 1.5 * It also creates and starts the ConnectionHandler which is the
16     * main thread for this application
17     *
18 ajm 1.4 * @author $Author: ajm4 $
19 ajm 1.7 * @version $Id: ControlPanel.java,v 1.6 2001/02/05 00:52:03 ajm4 Exp $
20 ajm 1.4 */
21 ajm 1.1 public class ControlPanel extends JPanel {
22 ajm 1.4
23     //---FINAL ATTRIBUTES---
24    
25     /**
26     * The current CVS revision of this class
27     */
28 ajm 1.7 public final String REVISION = "$Revision: 1.6 $";
29 ajm 1.4
30     //---STATIC METHODS---
31    
32     //---CONSTRUCTORS---
33    
34 ajm 1.5 /**
35     * Constructs a new ControlPanel.
36     *
37     * @param data the data panel to be passed to the ConnectionHandler
38     */
39 ajm 1.1 public ControlPanel(DataPanel data) {
40     super();
41     setLayout(new BorderLayout());
42 ajm 1.5 _handler = new ConnectionHandler(data, _actionQueue);
43 ajm 1.1 add(_toolBar, "North");
44     _handler.start();
45     }
46 ajm 1.4
47     //---PUBLIC METHODS---
48    
49     //---PRIVATE METHODS---
50    
51 ajm 1.5 /**
52     * Sets up the tool bar, adding action listeners
53     * to dispatch events to the ConnectionHandler
54     */
55 ajm 1.1 private JToolBar setupToolBar() {
56 ajm 1.6 JButton connectButton = new JButton("Connect", new ImageIcon("./uk/ac/ukc/iscream/conient/control16.gif"));
57 ajm 1.1 connectButton.addActionListener(new ActionListener() {
58     public void actionPerformed(ActionEvent e) {
59     _actionQueue.add(new Integer(ConnectionHandler.CONNECT));
60     }
61     });
62    
63 ajm 1.6 JButton startDataButton = new JButton("Start Data", new ImageIcon("./uk/ac/ukc/iscream/conient/data16.gif"));
64 ajm 1.2 startDataButton.addActionListener(new ActionListener() {
65     public void actionPerformed(ActionEvent e) {
66     _actionQueue.add(new Integer(ConnectionHandler.STARTDATA));
67     }
68     });
69    
70 ajm 1.6 JButton stopDataButton = new JButton("Stop Data", new ImageIcon("./uk/ac/ukc/iscream/conient/stop16.gif"));
71 ajm 1.2 stopDataButton.addActionListener(new ActionListener() {
72     public void actionPerformed(ActionEvent e) {
73     _actionQueue.add(new Integer(ConnectionHandler.STOPDATA));
74     }
75     });
76    
77 ajm 1.6 JButton disconnectButton = new JButton("Disconnect", new ImageIcon("./uk/ac/ukc/iscream/conient/stop16.gif"));
78 ajm 1.2 disconnectButton.addActionListener(new ActionListener() {
79     public void actionPerformed(ActionEvent e) {
80     _actionQueue.add(new Integer(ConnectionHandler.DISCONNECT));
81     }
82     });
83    
84 ajm 1.6 JButton quitButton = new JButton("Quit", new ImageIcon("./uk/ac/ukc/iscream/conient/stop16.gif"));
85 ajm 1.3 quitButton.addActionListener(new ActionListener() {
86     public void actionPerformed(ActionEvent e) {
87     _actionQueue.add(new Integer(ConnectionHandler.QUIT));
88     }
89     });
90    
91 ajm 1.1 JToolBar bar = new JToolBar(JToolBar.HORIZONTAL);
92     bar.add(connectButton);
93 ajm 1.2 bar.add(startDataButton);
94     bar.add(stopDataButton);
95     bar.add(disconnectButton);
96 ajm 1.3 bar.add(quitButton);
97 ajm 1.6 bar.add(Box.createGlue());
98     JLabel image = new JLabel(new ImageIcon("./uk/ac/ukc/iscream/conient/i-scream.gif"));
99     bar.add(image);
100 ajm 1.1 return bar;
101     }
102    
103 ajm 1.4 //---ACCESSOR/MUTATOR METHODS---
104    
105     //---ATTRIBUTES---
106    
107 ajm 1.5 /**
108     * The tool bar for the control panel
109     */
110 ajm 1.1 JToolBar _toolBar = setupToolBar();
111    
112 ajm 1.5 /**
113     * The queue that we will add actions to.
114     */
115 ajm 1.1 Queue _actionQueue = new Queue();
116 ajm 1.5
117     /**
118     * The connection handler in use by the system.
119     */
120 ajm 1.1 ConnectionHandler _handler;
121 ajm 1.4
122     //---STATIC ATTRIBUTES---
123    
124     }