I'm currently creating a GUI program that is basically a timer by using only threading. I am currently having a program with my if statements. Please help.
@Override
public void run() {
while (count2 != 0) {
try {
Thread.sleep(1000);
if (b == 0 && a > 0) {
b = 60;
a -= 1;
}
if (b > 59) {
a += 1;
b = 0;
}
if (c < 61 && c > 0) {
c -= 1;
}
if (c > 59) {
b += 1;
c = 60;
c -= 1;
}
if (b > 0 && b < 60 && c == 0) {
b -= 1;
c = 60;
}
jLabel4.setText("" + c);
jLabel5.setText("" + b);
jLabel6.setText("" + a);
count2--;
} catch (InterruptedException ex) {
Logger.getLogger(Timer.class.getName()).log(Level.SEVERE, null, ex);
}
}
JOptionPane.showMessageDialog(this, "Time's up");
}
A is hours B is minutes C is seconds
count2 = (a * 360) + (b * 60) + c;
Thank you :)