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.12
Committed: Mon Jan 22 05:11:40 2001 UTC (23 years, 3 months ago) by ajm
Branch: MAIN
Changes since 1.11: +19 -12 lines
Log Message:
nicer status...still not quite right though....

oh...and it should quit!

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.12 * @version $Id: SwingClient.java,v 1.11 2001/01/22 04:45:58 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.12 public final String REVISION = "$Revision: 1.11 $";
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 ajm 1.1 }
59 ajm 1.9
60 ajm 1.1
61     //---CONSTRUCTORS---
62    
63     /**
64 ajm 1.9 * Creates a new Swing Client Frame
65 ajm 1.1 */
66 ajm 1.9 private SwingClient(JPanel data, JPanel control) {
67     // set up the Frame
68     super("I-Scream Client");
69 ajm 1.8
70 ajm 1.9 setSize(width, height);
71     addWindowListener(new WindowAdapter() {
72     public void windowClosing(WindowEvent e) {System.exit(0);}
73     });
74 ajm 1.8
75 ajm 1.4
76 ajm 1.1 // build the frame
77 ajm 1.9 getContentPane().add(control, "North");
78     getContentPane().add(data, "Center");
79    
80     JPanel bottom = new JPanel();
81     bottom.setLayout(new BorderLayout());
82     _messages.setEditable(false);
83     _messages.setRows(3);
84     JScrollPane messagesPane = new JScrollPane(_messages);
85     messagesPane.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 102)), " Messages "));
86    
87     bottom.add(messagesPane, "Center");
88 ajm 1.11 JPanel statusPanel = new JPanel();
89 ajm 1.12 JPanel linkPanel = new JPanel();
90     linkPanel.setLayout(new GridLayout(2,1));
91     linkPanel.add(_controlStatus);
92     linkPanel.add(_dataStatus);
93 ajm 1.11 statusPanel.setLayout(new GridLayout(1,3));
94 ajm 1.12 statusPanel.add(linkPanel);
95 ajm 1.11 statusPanel.add(_queueStatus);
96    
97     bottom.add(statusPanel, "South");
98 ajm 1.9 getContentPane().add(bottom, "South");
99 ajm 1.8
100 ajm 1.1 // show the window
101     show();
102     }
103    
104     //---PUBLIC METHODS---
105    
106     //---PRIVATE METHODS---
107    
108 ajm 1.9 //---ACCESSOR/MUTATOR METHODS---
109 ajm 1.1
110 ajm 1.12 public static void setControlStatus(String status) {
111     _controlStatus.setText("Control Link: " + status);
112     _controlStatus.repaint();
113     }
114    
115     public static void setDataStatus(String status) {
116     _dataStatus.setText("Data Link: " + status);
117     _dataStatus.repaint();
118 ajm 1.9 }
119 ajm 1.1
120 ajm 1.11 public static void setQueueStatus(int currentQueue, int numElements) {
121     _queueStatus.setText("Data Queue : " + currentQueue + " Packets Recieved : " + numElements);
122     _queueStatus.repaint();
123     }
124    
125 ajm 1.9 public static void addMessage(String message) {
126     _messages.insert(message + "\n", 0);
127     }
128 ajm 1.1 //---ATTRIBUTES---
129 ajm 1.5
130 ajm 1.12 static JLabel _controlStatus = new JLabel("Control Link: Disconnected", JLabel.LEFT);
131 ajm 1.9 {
132 ajm 1.12 _controlStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
133 ajm 1.11 }
134    
135 ajm 1.12 static JLabel _dataStatus = new JLabel("Data Link: Disconnected", JLabel.LEFT);
136 ajm 1.11 {
137 ajm 1.12 _dataStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
138 ajm 1.11 }
139    
140     static JLabel _queueStatus = new JLabel("-", JLabel.LEFT);
141     {
142     _queueStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
143     }
144 ajm 1.9
145 ajm 1.4 ImageIcon _serverIcon = new ImageIcon("server.gif");
146 ajm 1.7 JLabel _serverCountLabel;
147     int _serverCount = 0;
148 ajm 1.9 static JTextArea _messages = new JTextArea();
149 ajm 1.8
150 ajm 1.1 //---STATIC ATTRIBUTES---
151    
152 ajm 1.8 }