burkan.java
import javax.swing.*;
public class burkan {
public static void main(String[] args){
Thread t1 = new Thread(new threads(300,300,1500));
Thread t2 = new Thread(new threads(250,250,3500));
Thread t3 = new Thread(new threads(200,200,6500));
Thread t4 = new Thread(new threads(100,100,8500));
Thread t5 = new Thread(new threads(50,50,10500));
t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
}
}
graphics.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class graphics extends JPanel{
private int a,b;
public graphics(int i, int j) {
//constructor
a=i;
b=j;
}
public void paintComponent(Graphics g){
super.paintComponents(g);
this.setBackground(Color.WHITE);
g.setColor(Color.blue);
g.drawRect(100,100, a, b);
}
}
threads.java
import java.util.*;
import java.awt.*;
import javax.swing.*;
public class threads implements Runnable{
private int x,y;
public int time;
public JFrame f = new JFrame("LOOP");
public threads(int a,int b,int t){
//constructor
x=a;
y=b;
time = t;
}
public void run(){
try{
Thread.sleep(time);
graphics p = new graphics(x,y);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(800,600);
f.setVisible(true);
f.add(p);
}catch(Exception e){}
}
}