Bom dia galera,estou com um codigo mas to com duvida de como chamar ele no meu frame , criei uma label para mostrar o relogio em funcionamento:
segue o cod
[code]public class Relogio extends JLabel {
private final DateFormat format;
public Relogio() {
format = new SimpleDateFormat("HH:mm");
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
doTime();
try {
Thread.sleep(59000L);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
break;
}
}
}
}, "Relogio");
thread.setDaemon(true);
thread.setPriority(Thread.MIN_PRIORITY + 1);
thread.start();
}
private void doTime() {
super.setText(format.format(new Date()));
}
@Override
public void setText(String text) {
}
} [/code]