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