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 |
|
|
75 |
|
messagesPane.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 102)), " Messages ")); |
76 |
|
|
77 |
|
bottom.add(messagesPane, "Center"); |
78 |
< |
bottom.add(_status, "South"); |
78 |
> |
JPanel statusPanel = new JPanel(); |
79 |
> |
JPanel linkPanel = new JPanel(); |
80 |
> |
linkPanel.setLayout(new GridLayout(2,1)); |
81 |
> |
linkPanel.add(_controlStatus); |
82 |
> |
linkPanel.add(_dataStatus); |
83 |
> |
statusPanel.setLayout(new GridLayout(1,3)); |
84 |
> |
statusPanel.add(linkPanel); |
85 |
> |
statusPanel.add(_queueStatus); |
86 |
> |
|
87 |
> |
bottom.add(statusPanel, "South"); |
88 |
|
getContentPane().add(bottom, "South"); |
89 |
|
|
90 |
|
// show the window |
97 |
|
|
98 |
|
//---ACCESSOR/MUTATOR METHODS--- |
99 |
|
|
100 |
< |
public static void setStatus(String status) { |
101 |
< |
_status.setText(status); |
102 |
< |
_status.repaint(); |
100 |
> |
public static void setControlStatus(String status) { |
101 |
> |
_controlStatus.setText("Control Link: " + status); |
102 |
> |
_controlStatus.repaint(); |
103 |
|
} |
104 |
+ |
|
105 |
+ |
public static void setDataStatus(String status) { |
106 |
+ |
_dataStatus.setText("Data Link: " + status); |
107 |
+ |
_dataStatus.repaint(); |
108 |
+ |
} |
109 |
|
|
110 |
+ |
public static void setQueueStatus(int currentQueue, int numElements) { |
111 |
+ |
_queueStatus.setText("Data Queue : " + currentQueue + " Packets Recieved : " + numElements); |
112 |
+ |
_queueStatus.repaint(); |
113 |
+ |
} |
114 |
+ |
|
115 |
|
public static void addMessage(String message) { |
116 |
|
_messages.insert(message + "\n", 0); |
117 |
|
} |
110 |
– |
//---ATTRIBUTES--- |
118 |
|
|
119 |
< |
static JLabel _status = new JLabel("Initialising", JLabel.LEFT); |
113 |
< |
{ |
114 |
< |
_status.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); |
115 |
< |
} |
119 |
> |
//---ATTRIBUTES--- |
120 |
|
|
121 |
|
ImageIcon _serverIcon = new ImageIcon("server.gif"); |
122 |
|
JLabel _serverCountLabel; |
123 |
|
int _serverCount = 0; |
120 |
– |
static JTextArea _messages = new JTextArea(); |
124 |
|
|
125 |
|
//---STATIC ATTRIBUTES--- |
126 |
|
|
127 |
+ |
static JLabel _controlStatus = new JLabel("Control Link: Disconnected", JLabel.LEFT); |
128 |
+ |
{ |
129 |
+ |
_controlStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); |
130 |
+ |
} |
131 |
+ |
|
132 |
+ |
static JLabel _dataStatus = new JLabel("Data Link: Disconnected", JLabel.LEFT); |
133 |
+ |
{ |
134 |
+ |
_dataStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); |
135 |
+ |
} |
136 |
+ |
|
137 |
+ |
static JLabel _queueStatus = new JLabel(" ", JLabel.LEFT); |
138 |
+ |
{ |
139 |
+ |
_queueStatus.setBorder(new EtchedBorder(EtchedBorder.LOWERED)); |
140 |
+ |
} |
141 |
+ |
static JTextArea _messages = new JTextArea(); |
142 |
|
} |