1 |
+ |
/* |
2 |
+ |
* i-scream central monitoring system |
3 |
+ |
* http://www.i-scream.org.uk |
4 |
+ |
* Copyright (C) 2000-2002 i-scream |
5 |
+ |
* |
6 |
+ |
* This program is free software; you can redistribute it and/or |
7 |
+ |
* modify it under the terms of the GNU General Public License |
8 |
+ |
* as published by the Free Software Foundation; either version 2 |
9 |
+ |
* of the License, or (at your option) any later version. |
10 |
+ |
* |
11 |
+ |
* This program is distributed in the hope that it will be useful, |
12 |
+ |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
+ |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
+ |
* GNU General Public License for more details. |
15 |
+ |
* |
16 |
+ |
* You should have received a copy of the GNU General Public License |
17 |
+ |
* along with this program; if not, write to the Free Software |
18 |
+ |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 |
+ |
*/ |
20 |
+ |
|
21 |
|
//---PACKAGE DECLARATION--- |
22 |
< |
package uk.ac.ukc.iscream.conient; |
22 |
> |
package uk.org.iscream.cms.conient; |
23 |
|
|
24 |
|
//---IMPORTS--- |
25 |
|
import javax.swing.JProgressBar; |
26 |
+ |
import javax.swing.JPanel; |
27 |
+ |
import javax.swing.JLabel; |
28 |
+ |
import javax.swing.BoxLayout; |
29 |
|
import javax.swing.SwingUtilities; |
30 |
|
|
31 |
|
/** |
42 |
|
* @author $Author$ |
43 |
|
* @version $Id$ |
44 |
|
*/ |
45 |
< |
public class PacketTimer extends JProgressBar implements Runnable { |
45 |
> |
public class PacketTimer extends JPanel implements Runnable { |
46 |
|
|
47 |
|
//---FINAL ATTRIBUTES--- |
48 |
|
|
60 |
|
* |
61 |
|
* @param timeBetweenPackets the time in seconds between packet arrival |
62 |
|
*/ |
63 |
< |
public PacketTimer(int timeBetweenPackets) { |
41 |
< |
super(JProgressBar.VERTICAL, 0, (timeBetweenPackets * 10) + 1); |
63 |
> |
public PacketTimer(String name, int timeBetweenPackets) { |
64 |
|
_timeBetweenPackets = timeBetweenPackets * 10; |
65 |
< |
setMaximum(_timeBetweenPackets); |
65 |
> |
_progressBar = new JProgressBar(JProgressBar.HORIZONTAL, 0, _timeBetweenPackets); |
66 |
> |
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
67 |
> |
JLabel label = new JLabel(name); |
68 |
> |
this.add(_progressBar); |
69 |
> |
this.add(label); |
70 |
|
} |
71 |
|
|
72 |
|
//---PUBLIC METHODS--- |
83 |
|
|
84 |
|
SwingUtilities.invokeLater(new Runnable() { |
85 |
|
public void run() { |
86 |
< |
PacketTimer.this.setValue(PacketTimer.this.getValue() - 1); |
86 |
> |
_progressBar.setValue(_progressBar.getValue() - 1); |
87 |
|
} |
88 |
|
}); |
89 |
|
} |
95 |
|
public void reset() { |
96 |
|
SwingUtilities.invokeLater(new Runnable() { |
97 |
|
public void run() { |
98 |
< |
PacketTimer.this.setValue(_timeBetweenPackets); |
98 |
> |
_progressBar.setValue(_timeBetweenPackets); |
99 |
|
} |
100 |
|
}); |
101 |
|
} |
115 |
|
* Used to indicate the state of the thread |
116 |
|
*/ |
117 |
|
private boolean _running = true; |
118 |
+ |
|
119 |
+ |
private JProgressBar _progressBar; |
120 |
|
|
121 |
|
//---STATIC ATTRIBUTES--- |
122 |
|
|