Ciao a tutti… eccomi intanto con un altro problema 
Ho creato un timer che mi serve a scandire il tempo…
codice:
JTextField tempo;
Thread t = null;
Watch watch = new Watch();
public class Watch implements Runnable {
int hours = 0;
int minutes = 0;
int seconds = 0;
boolean runTimer = true;
public void isRunning(boolean value) {
runTimer = value;
}
public void run() {
Timer timer = new Timer(1000, new TimerListenerClass());
timer.start();
while (runTimer) {
tempo.setText(hours + ":" + minutes + ":" + seconds);
}
}
class TimerListenerClass implements ActionListener {
@Override
public void actionPerformed(ActionEvent arg0) {
seconds += 1;
if (seconds > 59) {
seconds = 0;
minutes += 1;
}
if (minutes > 59) {
minutes = 0;
hours += 1;
}
}
}
}
Dopo di che ho creato un gestore di bottoni (bottoni che ho inserito in un jpanel)…
i bottoni sono: avvio, pausa, stop:
codice:
private class GestoreBottoni implements ActionListener {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == avvio) {
if (t == null) {
t = new Thread (watch);
t.start();
avvio.setEnabled(false);
pausa.setEnabled(true);
stop.setEnabled(true);
} else {
watch.isRunning(true);
}
} else if (e.getSource() == pausa) {
watch.isRunning(false);
avvio.setEnabled(true);
} else if (e.getSource() == stop) {
watch.isRunning(false);
pausa.setEnabled(false);
}
}
}
Quando premo il bottone ‘avvio’ deve partire il tempo e stampare il tempo che passa sul jtextField ‘tempo’. Successivamente posso premere il bottone ‘stop’ per bloccare il timer, oppure ‘pausa’ per sospenderlo e poterlo riavviare successivamente da dove l’avevo interrotto.
Il mio problema è che non riesco a mettere in pausa il timer e riavviarlo… ho provato ad usare t.suspend() e t.resume() ma mi vengono barrate e mi esce scritto che sono obsolete… come potrei fare?