swing
minuterie dans JFrame
Recherche…
Timer In JFrame
Supposons que votre programme Java comporte un bouton qui décompte un temps. Voici le code pour 10 minutes.
private final static long REFRESH_LIST_PERIOD=10 * 60 * 1000; //10 minutes
Timer timer = new Timer(1000, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (cnt > 0) {
cnt = cnt - 1000;
btnCounter.setText("Remained (" + format.format(new Date(cnt)) + ")");
} else {
cnt = REFRESH_LIST_PERIOD;
//TODO
}
}
});
timer.start();
Modified text is an extract of the original Stack Overflow Documentation
Sous licence CC BY-SA 3.0
Non affilié à Stack Overflow