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

# 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.Color;
7 ajm 1.8 import uk.ac.ukc.iscream.util.*;
8 ajm 1.1
9     import java.awt.*;
10     import java.awt.event.*;
11     import java.net.*;
12     import java.io.*;
13 ajm 1.2 import java.util.Date;
14     import java.text.DateFormat;
15     import java.util.Locale;
16 ajm 1.4 import java.util.HashMap;
17 ajm 1.8 import javax.swing.border.*;
18 ajm 1.1
19     /**
20     * NASTY AND BASIC, PLEASE DON'T COMPLAIN
21     *
22     * @author $Author: ajm4 $
23 ajm 1.11 * @version $Id: SwingClient.java,v 1.10 2001/01/22 03:03:39 ajm4 Exp $
24 ajm 1.1 */
25 ajm 1.9 public class SwingClient extends JFrame {
26 ajm 1.1
27     //---FINAL ATTRIBUTES---
28    
29     /**
30     * The current CVS revision of this class
31     */
32 ajm 1.11 public final String REVISION = "$Revision: 1.10 $";
33 ajm 1.10
34 ajm 1.9 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 ajm 1.1
40     //---STATIC METHODS---
41    
42     public static void main(String[] args) {
43 ajm 1.9 // 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 ajm 1.8
49 ajm 1.9 // the data display panel
50     DataPanel data = new DataPanel();
51    
52     // the control panel
53     ControlPanel control = new ControlPanel(data);
54 ajm 1.1
55 ajm 1.9 // the main frame (passed the two panels)
56     SwingClient client = new SwingClient(data, control);
57     SwingClient.addMessage("Client started");
58     SwingClient.setStatus("Disconnected");
59 ajm 1.1 }
60 ajm 1.9
61 ajm 1.1
62     //---CONSTRUCTORS---
63    
64     /**
65 ajm 1.9 * Creates a new Swing Client Frame
66 ajm 1.1 */
67 ajm 1.9 private SwingClient(JPanel data, JPanel control) {
68     // set up the Frame
69     super("I-Scream Client");
70 ajm 1.8
71 ajm 1.9 setSize(width, height);
72     addWindowListener(new WindowAdapter() {
73     public void windowClosing(WindowEvent e) {System.exit(0);}
74     });
75 ajm 1.8
76 ajm 1.4
77 ajm 1.1 // build the frame
78 ajm 1.9 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 ajm 1.11 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 ajm 1.9 getContentPane().add(bottom, "South");
97 ajm 1.8
98 ajm 1.1 // show the window
99     show();
100     }
101    
102     //---PUBLIC METHODS---
103    
104     //---PRIVATE METHODS---
105    
106 ajm 1.9 //---ACCESSOR/MUTATOR METHODS---
107 ajm 1.1
108 ajm 1.9 public static void setStatus(String status) {
109     _status.setText(status);
110     _status.repaint();
111     }
112 ajm 1.1
113 ajm 1.11 public static void setQueueStatus(int currentQueue, int numElements) {
114     _queueStatus.setText("Data Queue : " + currentQueue + " Packets Recieved : " + numElements);
115     _queueStatus.repaint();
116     }
117    
118 ajm 1.9 public static void addMessage(String message) {
119     _messages.insert(message + "\n", 0);
120     }
121 ajm 1.1 //---ATTRIBUTES---
122 ajm 1.5
123 ajm 1.9 static JLabel _status = new JLabel("Initialising", JLabel.LEFT);
124     {
125     _status.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
126 ajm 1.11 }
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 ajm 1.9
138 ajm 1.4 ImageIcon _serverIcon = new ImageIcon("server.gif");
139 ajm 1.7 JLabel _serverCountLabel;
140     int _serverCount = 0;
141 ajm 1.9 static JTextArea _messages = new JTextArea();
142 ajm 1.8
143 ajm 1.1 //---STATIC ATTRIBUTES---
144    
145 ajm 1.8 }