|
|
@ -0,0 +1,38 @@ |
|
|
|
package Minesweeper; |
|
|
|
|
|
|
|
import java.util.Timer; |
|
|
|
import java.util.TimerTask; |
|
|
|
|
|
|
|
import javax.swing.JLabel; |
|
|
|
|
|
|
|
public class TimerLable extends JLabel { |
|
|
|
|
|
|
|
private static final long serialVersionUID = 1L; |
|
|
|
private int counter = 0; |
|
|
|
|
|
|
|
public void start() { |
|
|
|
Timer timer = new Timer(); |
|
|
|
TimerTask task = new Helper(this); |
|
|
|
|
|
|
|
timer.schedule(task, 0, 1000); |
|
|
|
} |
|
|
|
|
|
|
|
public void update() { |
|
|
|
setText(String.valueOf(++counter)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class Helper extends TimerTask |
|
|
|
{ |
|
|
|
public static int i = 0; |
|
|
|
private TimerLable timerLable; |
|
|
|
|
|
|
|
public Helper(TimerLable _timerLable) { |
|
|
|
timerLable = _timerLable; |
|
|
|
} |
|
|
|
public void run() |
|
|
|
{ |
|
|
|
timerLable.update(); |
|
|
|
} |
|
|
|
} |