import java.awt.*; import java.awt.event.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; public class neljandale2 extends Frame implements Runnable{ neljas foor=new neljas(); neljas foor2=new neljas(); Frame aken=new Frame(); boolean veel=true; public neljandale2(){ aken.setSize(300, 200); aken.setTitle("foorid"); Panel paneel=new Panel(new GridLayout(1, 2)); paneel.add(foor); paneel.add(foor2); aken.add(paneel); aken.addWindowListener(new aknakuular()); aken.setVisible(true); new Thread(this).start(); } public void run(){ while(veel==true){ foor.varvid(Color.red,Color.white,Color.white); foor2.varvid(Color.white,Color.white,Color.green); try{Thread.sleep(1000);}catch(Exception e){} foor.varvid(Color.white,Color.yellow,Color.white); foor2.varvid(Color.white,Color.yellow,Color.white); try{Thread.sleep(1000);}catch(Exception e){} foor.varvid(Color.white,Color.white,Color.green); foor2.varvid(Color.red,Color.white,Color.white); try{Thread.sleep(1000);}catch(Exception e){} foor.varvid(Color.white,Color.yellow,Color.white); foor2.varvid(Color.white,Color.yellow,Color.white); try{Thread.sleep(1000);}catch(Exception e){} } } public static void main(String argumendid[]){ new neljandale2(); } } class aknakuular extends WindowAdapter{ public void windowClosing(WindowEvent e){ System.exit(0); } }