3 |
|
//---IMPORTS--- |
4 |
|
import javax.swing.*; |
5 |
|
import javax.swing.border.*; |
6 |
– |
import java.awt.Color; |
7 |
– |
import uk.ac.ukc.iscream.util.*; |
8 |
– |
|
6 |
|
import java.awt.*; |
7 |
|
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.*; |
8 |
|
|
9 |
|
/** |
10 |
< |
* NASTY AND BASIC, PLEASE DON'T COMPLAIN |
10 |
> |
* Root for the SwingClient...starts the whole show off... |
11 |
|
* |
12 |
|
* @author $Author$ |
13 |
|
* @version $Id$ |
20 |
|
* The current CVS revision of this class |
21 |
|
*/ |
22 |
|
public final String REVISION = "$Revision$"; |
23 |
< |
|
23 |
> |
|
24 |
|
private final int width = 600; |
25 |
|
private final int height = 600; |
26 |
|
|
45 |
|
// the main frame (passed the two panels) |
46 |
|
SwingClient client = new SwingClient(data, control); |
47 |
|
SwingClient.addMessage("Client started"); |
58 |
– |
SwingClient.setStatus("Disconnected"); |
48 |
|
} |
49 |
|
|
50 |
|
|
62 |
|
public void windowClosing(WindowEvent e) {System.exit(0);} |
63 |
|
}); |
64 |
|
|
76 |
– |
|
77 |
– |
// build the frame |
65 |
|
getContentPane().add(control, "North"); |
79 |
– |
getContentPane().add(data, "Center"); |
66 |
|
|
67 |
+ |
JScrollPane scrollPane = new JScrollPane(data); |
68 |
+ |
getContentPane().add(scrollPane, "Center"); |
69 |
+ |
|
70 |
+ |
|
71 |
|
JPanel bottom = new JPanel(); |
72 |
|
bottom.setLayout(new BorderLayout()); |
73 |
|
_messages.setEditable(false); |
76 |
|
messagesPane.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 102)), " Messages ")); |
77 |
|
|
78 |
|
bottom.add(messagesPane, "Center"); |
79 |
< |
bottom.add(_status, "South"); |
79 |
> |
JPanel statusPanel = new JPanel(); |
80 |
> |
JPanel linkPanel = new JPanel(); |
81 |
> |
linkPanel.setLayout(new GridLayout(2,1)); |
82 |
> |
linkPanel.add(_controlStatus); |
83 |
> |
linkPanel.add(_dataStatus); |
84 |
> |
statusPanel.setLayout(new GridLayout(1,3)); |
85 |
> |
statusPanel.add(linkPanel); |
86 |
> |
statusPanel.add(_queueStatus); |
87 |
> |
|
88 |
> |
bottom.add(statusPanel, "South"); |
89 |
|
getContentPane().add(bottom, "South"); |
90 |
|
|
91 |
|
// show the window |
98 |
|
|
99 |
|
//---ACCESSOR/MUTATOR METHODS--- |
100 |
|
|
101 |
< |
public static void setStatus(String status) { |
102 |
< |
_status.setText(status); |
103 |
< |
_status.repaint(); |
101 |
> |
public static void setControlStatus(String status) { |
102 |
> |
_controlStatus.setText("Control Link: " + status); |
103 |
> |
_controlStatus.repaint(); |
104 |
|
} |
105 |
+ |
|
106 |
+ |
public static void setDataStatus(String status) { |
107 |
+ |
_dataStatus.setText("Data Link: " + status); |
108 |
+ |
_dataStatus.repaint(); |
109 |
+ |
} |
110 |
|
|
111 |
+ |
public static void setQueueStatus(int currentQueue, int numElements) { |
112 |
+ |
_queueStatus.setText("Data Queue : " + currentQueue + " Packets Recieved : " + numElements); |
113 |
+ |
_queueStatus.repaint(); |
114 |
+ |
} |
115 |
+ |
|
116 |
|
public static void addMessage(String message) { |
117 |
|
_messages.insert(message + "\n", 0); |
118 |
|
} |
110 |
– |
//---ATTRIBUTES--- |
119 |
|
|
120 |
< |
static JLabel _status = new JLabel("Initialising", JLabel.LEFT); |
113 |
< |
{ |
114 |
< |
_status.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); |
115 |
< |
} |
120 |
> |
//---ATTRIBUTES--- |
121 |
|
|
122 |
|
ImageIcon _serverIcon = new ImageIcon("server.gif"); |
123 |
|
JLabel _serverCountLabel; |
124 |
|
int _serverCount = 0; |
120 |
– |
static JTextArea _messages = new JTextArea(); |
125 |
|
|
126 |
|
//---STATIC ATTRIBUTES--- |
127 |
|
|
128 |
+ |
static JLabel _controlStatus = new JLabel("Control Link: Disconnected", JLabel.LEFT); |
129 |
+ |
{ |
130 |
+ |
_controlStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); |
131 |
+ |
} |
132 |
+ |
|
133 |
+ |
static JLabel _dataStatus = new JLabel("Data Link: Disconnected", JLabel.LEFT); |
134 |
+ |
{ |
135 |
+ |
_dataStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); |
136 |
+ |
} |
137 |
+ |
|
138 |
+ |
static JLabel _queueStatus = new JLabel(" ", JLabel.LEFT); |
139 |
+ |
{ |
140 |
+ |
_queueStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); |
141 |
+ |
} |
142 |
+ |
static JTextArea _messages = new JTextArea(); |
143 |
|
} |