Ứng dụng Lập trình tuyến đoạn
@Override
public void run() {
while (true) {
try {
//Thiet lap den xanh
tatThoiGian();
tatTatCaCacDen();
lbXanh.setBackground(Color.GREEN);
for (int i = 20; i >= 0; i--) {
txtXanh.setText("Xanh - " + i + " giay");
Thread.sleep(1000);
}
tatThoiGian();
//Thiet lap den do
tatTatCaCacDen();
lbDo.setBackground(Color.RED);
for (int i = 10; i >= 0; i--) {
txtDo.setText("Do - " + i + " s");
Thread.sleep(1000);
}
//Thiet lap den vang
tatThoiGian();
tatTatCaCacDen();
lbVang.setBackground(Color.YELLOW);
for (int i = 3; i >= 0; i--) {
txtVang.setText("Vang - " + i + " s");
Thread.sleep(1000);
}
} catch (InterruptedException e) {
break;
}
}
}