im trying to make the light auto changing with implementing runnable but i got runtime error cause of no constructor found for thread any idea wht i hav to do to make it run
import java.awt.*; import javax.swing.*; public class lamp extends JFrame implements Runnable { Signal green = new Signal(Color.green); Signal yellow = new Signal(Color.yellow); Signal red = new Signal(Color.red); S public void run() { boolean nyala = true; while(nyala) { try { if (nyala) { red.turnOn(false); yellow.turnOn(false); green.turnOn(true); } else { red.turnOn(true); yellow.turnOn(false); green.turnOn(false); } } catch (Exception e) { } nyala = !nyala; } } public lamp(){ super("Traffic Light"); getContentPane().setLayout(new GridLayout(2,2,25,25)); green.turnOn(false); yellow.turnOn(false); red.turnOn(true); JPanel p1 = new JPanel(new GridLayout(3,1)); p1.add(red); p1.add(yellow); p1.add(green); getContentPane().add(p1); pack(); new Thread(red).start(); } public static void main(String[] args){ lamp tl = new lamp(); tl.setVisible(true); } } class Signal extends JPanel{ Color on; int radius = 40; int border = 10; boolean change; Signal(Color color){ on = color; change = true; } public void turnOn(boolean a){ change = a; repaint(); } public Dimension getPreferredSize(){ int size = (radius+border)*2; return new Dimension( size, size ); } public void paintComponent(Graphics g){ g.setColor( Color.black ); g.fillRect(0,0,getWidth(),getHeight()); if (change){ g.setColor( on ); } else { g.setColor( on.darker().darker().darker() ); } g.fillOval( border,border,2*radius,2*radius ); } }