Flicker function fixed!

This commit is contained in:
LinlyBoi
2023-03-07 17:55:34 +02:00
parent df185296dc
commit 386e69d744

View File

@@ -33,7 +33,7 @@ public class Light extends JPanel implements Runnable {
this(); this();
this.timeout = timeout; this.timeout = timeout;
this.color = color; this.color = color;
this.setBorder(BorderFactory.createLineBorder(Color.BLACK, 10)); // this.setBorder(BorderFactory.createLineBorder(Color.WHITE, 10));
setVisible(false); setVisible(false);
setBackground(Color.BLACK); setBackground(Color.BLACK);
} }
@@ -42,21 +42,21 @@ public class Light extends JPanel implements Runnable {
setVisible(true); setVisible(true);
try { try {
TimeUnit.SECONDS.sleep(timeout); TimeUnit.SECONDS.sleep(timeout - 2);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
setVisible(false); flicker();
// flicker();
} }
public void flicker() { public void flicker() {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 5; i++) {
try { try {
setVisible(false); setVisible(false);
TimeUnit.MILLISECONDS.sleep(500); TimeUnit.MILLISECONDS.sleep(250);
setVisible(true); setVisible(true);
TimeUnit.MILLISECONDS.sleep(250);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }