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.9
Committed: Sun Jan 21 03:30:00 2001 UTC (23 years, 3 months ago) by ajm
Branch: MAIN
Changes since 1.8: +58 -129 lines
Log Message:
modified to have better support for threads and application layout.
all ready to start implementing a protocol too ;)

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.9 * @version $Id: SwingClient.java,v 1.8 2001/01/20 16:06:53 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.9 public final String REVISION = "$Revision: 1.8 $";
33 ajm 1.1
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     bottom.add(_status, "South");
90     getContentPane().add(bottom, "South");
91 ajm 1.8
92 ajm 1.1 // show the window
93     show();
94     }
95    
96     //---PUBLIC METHODS---
97    
98     //---PRIVATE METHODS---
99    
100 ajm 1.9 //---ACCESSOR/MUTATOR METHODS---
101 ajm 1.1
102 ajm 1.9 public static void setStatus(String status) {
103     _status.setText(status);
104     _status.repaint();
105     }
106 ajm 1.1
107 ajm 1.9 public static void addMessage(String message) {
108     _messages.insert(message + "\n", 0);
109     }
110 ajm 1.1 //---ATTRIBUTES---
111 ajm 1.5
112 ajm 1.9 static JLabel _status = new JLabel("Initialising", JLabel.LEFT);
113     {
114     _status.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
115     }
116    
117 ajm 1.4 ImageIcon _serverIcon = new ImageIcon("server.gif");
118 ajm 1.7 JLabel _serverCountLabel;
119     int _serverCount = 0;
120 ajm 1.9 static JTextArea _messages = new JTextArea();
121 ajm 1.8
122 ajm 1.1 //---STATIC ATTRIBUTES---
123    
124 ajm 1.8 }