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.11
Committed: Mon Jan 22 04:45:58 2001 UTC (23 years, 3 months ago) by ajm
Branch: MAIN
Changes since 1.10: +25 -4 lines
Log Message:
added nice status stuff for looking at the Queue

File Contents

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