made timer change color when time is up
This commit is contained in:
parent
bb0645491d
commit
9456b6305b
|
@ -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() {
|
||||||
|
|
Loading…
Reference in New Issue