ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/conient/uk/org/iscream/cms/conient/Conient.java
Revision: 1.14
Committed: Mon Jan 22 19:35:36 2001 UTC (23 years, 3 months ago) by tdb
Branch: MAIN
Changes since 1.13: +6 -5 lines
Log Message:
Mainly bug fixes and small features added.
eg, start data connects control link if not already there
eg, shows messages as new hosts are added
eg, scrolls the main central data panel
eg, cleans up old data panels when data is stopped and restarted

added more javadoc to some items

File Contents

# User Rev Content
1 ajm 1.1 //---PACKAGE DECLARATION---
2    
3     //---IMPORTS---
4     import javax.swing.*;
5     import javax.swing.border.*;
6     import java.awt.*;
7     import java.awt.event.*;
8    
9     /**
10 ajm 1.13 * Root for the SwingClient...starts the whole show off...
11 ajm 1.1 *
12     * @author $Author: ajm4 $
13 tdb 1.14 * @version $Id: SwingClient.java,v 1.13 2001/01/22 12:48:38 ajm4 Exp $
14 ajm 1.1 */
15 ajm 1.9 public class SwingClient extends JFrame {
16 ajm 1.1
17     //---FINAL ATTRIBUTES---
18    
19     /**
20     * The current CVS revision of this class
21     */
22 tdb 1.14 public final String REVISION = "$Revision: 1.13 $";
23 ajm 1.10
24 ajm 1.9 private final int width = 600;
25     private final int height = 600;
26    
27     // the well known port
28     public static final int PORT = 4510;
29 ajm 1.1
30     //---STATIC METHODS---
31    
32     public static void main(String[] args) {
33 ajm 1.9 // get the host from the command line if they gave it
34     String host = null;
35     if (args.length == 1) {
36     host = args[0];
37     }
38 ajm 1.8
39 ajm 1.9 // the data display panel
40     DataPanel data = new DataPanel();
41    
42     // the control panel
43     ControlPanel control = new ControlPanel(data);
44 ajm 1.1
45 ajm 1.9 // the main frame (passed the two panels)
46     SwingClient client = new SwingClient(data, control);
47     SwingClient.addMessage("Client started");
48 ajm 1.1 }
49 ajm 1.9
50 ajm 1.1
51     //---CONSTRUCTORS---
52    
53     /**
54 ajm 1.9 * Creates a new Swing Client Frame
55 ajm 1.1 */
56 ajm 1.9 private SwingClient(JPanel data, JPanel control) {
57     // set up the Frame
58     super("I-Scream Client");
59 ajm 1.8
60 ajm 1.9 setSize(width, height);
61     addWindowListener(new WindowAdapter() {
62     public void windowClosing(WindowEvent e) {System.exit(0);}
63     });
64 ajm 1.8
65 tdb 1.14 getContentPane().add(control, "North");
66    
67     JScrollPane scrollPane = new JScrollPane(data);
68     getContentPane().add(scrollPane, "Center");
69 ajm 1.4
70 ajm 1.9
71     JPanel bottom = new JPanel();
72     bottom.setLayout(new BorderLayout());
73     _messages.setEditable(false);
74     _messages.setRows(3);
75     JScrollPane messagesPane = new JScrollPane(_messages);
76     messagesPane.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 102)), " Messages "));
77    
78     bottom.add(messagesPane, "Center");
79 ajm 1.11 JPanel statusPanel = new JPanel();
80 ajm 1.12 JPanel linkPanel = new JPanel();
81     linkPanel.setLayout(new GridLayout(2,1));
82     linkPanel.add(_controlStatus);
83     linkPanel.add(_dataStatus);
84 ajm 1.11 statusPanel.setLayout(new GridLayout(1,3));
85 ajm 1.12 statusPanel.add(linkPanel);
86 ajm 1.11 statusPanel.add(_queueStatus);
87    
88     bottom.add(statusPanel, "South");
89 ajm 1.9 getContentPane().add(bottom, "South");
90 ajm 1.8
91 ajm 1.1 // show the window
92     show();
93     }
94    
95     //---PUBLIC METHODS---
96    
97     //---PRIVATE METHODS---
98    
99 ajm 1.9 //---ACCESSOR/MUTATOR METHODS---
100 ajm 1.1
101 ajm 1.12 public static void setControlStatus(String status) {
102     _controlStatus.setText("Control Link: " + status);
103     _controlStatus.repaint();
104     }
105    
106     public static void setDataStatus(String status) {
107     _dataStatus.setText("Data Link: " + status);
108     _dataStatus.repaint();
109 ajm 1.9 }
110 ajm 1.1
111 ajm 1.11 public static void setQueueStatus(int currentQueue, int numElements) {
112     _queueStatus.setText("Data Queue : " + currentQueue + " Packets Recieved : " + numElements);
113     _queueStatus.repaint();
114     }
115    
116 ajm 1.9 public static void addMessage(String message) {
117     _messages.insert(message + "\n", 0);
118     }
119 ajm 1.13
120 ajm 1.1 //---ATTRIBUTES---
121 ajm 1.13
122     ImageIcon _serverIcon = new ImageIcon("server.gif");
123     JLabel _serverCountLabel;
124     int _serverCount = 0;
125    
126     //---STATIC ATTRIBUTES---
127    
128 ajm 1.12 static JLabel _controlStatus = new JLabel("Control Link: Disconnected", JLabel.LEFT);
129 ajm 1.9 {
130 ajm 1.12 _controlStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
131 ajm 1.11 }
132    
133 ajm 1.12 static JLabel _dataStatus = new JLabel("Data Link: Disconnected", JLabel.LEFT);
134 ajm 1.11 {
135 ajm 1.12 _dataStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
136 ajm 1.11 }
137    
138 ajm 1.13 static JLabel _queueStatus = new JLabel(" ", JLabel.LEFT);
139 ajm 1.11 {
140     _queueStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
141     }
142 ajm 1.9 static JTextArea _messages = new JTextArea();
143 ajm 1.8 }