made timer change color when time is up

This commit is contained in:
Lucas Pleß 2012-06-05 01:58:22 +02:00
parent bb0645491d
commit 9456b6305b
1 changed files with 23 additions and 0 deletions

View File

@ -50,6 +50,29 @@ public class MainGui extends JFrame implements IGuiControl {
int secs = tseconds % 600 / 10 ; int secs = tseconds % 600 / 10 ;
int tsecs = tseconds % 9; int tsecs = tseconds % 9;
countDown.setText(" " + mins + ":" + secs + "." + tsecs); countDown.setText(" " + mins + ":" + secs + "." + tsecs);
if(tseconds < 400) {
double percentile = ((tseconds-100.0)/300.0);
double red = 255.0 - percentile * 255.0;
double green = 255.0 - red;
double blue = percentile * 100.0;
// System.out.println("red= " + red + " green=" + green + " blue="+blue);
if(red > 255) red = 255;
if(red < 0) red = 0;
if(green > 255) green = 255;
if(green < 0) green = 0;
if(blue > 255) blue = 255;
if(blue < 0) blue = 0;
Color fColor = new Color((int)red,(int)green, (int)blue);
countDown.setForeground(fColor);
}
else {
countDown.setForeground(new Color(0x00, 190, 100));
}
} }
private void initGui() { private void initGui() {