1 |
|
//---PACKAGE DECLARATION--- |
2 |
< |
package uk.ac.ukc.iscream.conient; |
2 |
> |
package uk.org.iscream.cms.conient; |
3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
|
import javax.swing.JProgressBar; |
6 |
+ |
import javax.swing.JPanel; |
7 |
+ |
import javax.swing.JLabel; |
8 |
+ |
import javax.swing.BoxLayout; |
9 |
|
import javax.swing.SwingUtilities; |
10 |
|
|
11 |
|
/** |
22 |
|
* @author $Author$ |
23 |
|
* @version $Id$ |
24 |
|
*/ |
25 |
< |
public class PacketTimer extends JProgressBar implements Runnable { |
25 |
> |
public class PacketTimer extends JPanel implements Runnable { |
26 |
|
|
27 |
|
//---FINAL ATTRIBUTES--- |
28 |
|
|
40 |
|
* |
41 |
|
* @param timeBetweenPackets the time in seconds between packet arrival |
42 |
|
*/ |
43 |
< |
public PacketTimer(int timeBetweenPackets) { |
41 |
< |
super(JProgressBar.VERTICAL, 0, (timeBetweenPackets * 10) + 1); |
43 |
> |
public PacketTimer(String name, int timeBetweenPackets) { |
44 |
|
_timeBetweenPackets = timeBetweenPackets * 10; |
45 |
< |
setMaximum(_timeBetweenPackets); |
45 |
> |
_progressBar = new JProgressBar(JProgressBar.HORIZONTAL, 0, _timeBetweenPackets); |
46 |
> |
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
47 |
> |
JLabel label = new JLabel(name); |
48 |
> |
this.add(_progressBar); |
49 |
> |
this.add(label); |
50 |
|
} |
51 |
|
|
52 |
|
//---PUBLIC METHODS--- |
63 |
|
|
64 |
|
SwingUtilities.invokeLater(new Runnable() { |
65 |
|
public void run() { |
66 |
< |
PacketTimer.this.setValue(PacketTimer.this.getValue() - 1); |
66 |
> |
_progressBar.setValue(_progressBar.getValue() - 1); |
67 |
|
} |
68 |
|
}); |
69 |
|
} |
75 |
|
public void reset() { |
76 |
|
SwingUtilities.invokeLater(new Runnable() { |
77 |
|
public void run() { |
78 |
< |
PacketTimer.this.setValue(_timeBetweenPackets); |
78 |
> |
_progressBar.setValue(_timeBetweenPackets); |
79 |
|
} |
80 |
|
}); |
81 |
|
} |
95 |
|
* Used to indicate the state of the thread |
96 |
|
*/ |
97 |
|
private boolean _running = true; |
98 |
+ |
|
99 |
+ |
private JProgressBar _progressBar; |
100 |
|
|
101 |
|
//---STATIC ATTRIBUTES--- |
102 |
|
|