Hey there,
I have the following code:
public void paintComponent(Graphics d){
int gjeresia_e_kornizes = 800;
int lartesia_e_kornizes = 800;
d.setColor(Color.white);
d.fillRect(0, 0, gjeresia_e_kornizes, lartesia_e_kornizes);
d.setColor(Color.red);
d.fillOval(105, 70, 250, 350);
try { Thread.sleep(2000); }
catch (InterruptedException e) { }
d.setColor(Color.blue);
d.fillOval(150, 170, 50, 20);
d.fillOval(270, 170, 50, 20);
try { Thread.sleep(2000); }
catch (InterruptedException e) { }
d.setColor(Color.black);
d.drawLine(235, 200, 210, 310);
try { Thread.sleep(2000);
catch (InterruptedException e) { }
d.drawLine(210, 310, 270, 310);
d.drawLine(270, 310, 250, 290);}
try { Thread.sleep(2000);
catch (InterruptedException e) { }
d.drawLine(205, 340, 275, 340);
d.drawLine(205, 340, 190, 360);
d.drawLine(275, 340, 290, 360);
}
I expect the code above to draw lines and ovals with 2-second interuptions for each time the try-catch part appears in the code. However, what I get is:
first the frame object appears with nothing in it (i see my jGRASP behind the frame). after 8 seconds (that is four times two seconds - 2 seconds for each try-catch), all the lines and ovals, which make a face, appear at once.
I am really curious to know if there is any way to reach the effect I am aming at using this kind of simple code. besides, there is a similar assignment in a java book. the only difference is the types of shapes I am supposed to use. thanks in advance for any eventual help.