-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestTimer.java
64 lines (34 loc) · 1.53 KB
/
TestTimer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
public class TestTimer {
public void counter(JLabel label , final int[] timeRemaining , JFrame frame , int width , int height){
ImageIcon image = new ImageIcon("D:\\University\\Semester8\\AP\\Project_revise\\images\\time\\end_time.png");
JLabel imageLabel = new JLabel(image);
imageLabel.setBounds(0, 0, width, height);
imageLabel.setVisible(true);
Runnable r1 = new Runnable() {
public void run() {
try {
while (true) {
if (timeRemaining[0] > 0){
timeRemaining[0] = timeRemaining[0] - 1;
String time_in_jlable = new Integer(timeRemaining[0]).toString();
label.setText(time_in_jlable);
}
else {
//frame.dispatchEvent((new WindowEvent(frame, WindowEvent.WINDOW_CLOSING)));
frame.getContentPane().removeAll();
frame.setContentPane(imageLabel);
break;
}
Thread.sleep(1000L);
}
} catch (InterruptedException iex) {}
}
};
Thread thr1 = new Thread(r1);
thr1.start();
}
}