/*Hi! I want that after each line is drawn, it gets REMOVED before the transform is applied and the next line is drawn. repaint() won't work because it will run at its own will :-( I have made a call to setPaint(), and then fill() functions of Graphics2D object. Is this the right approach? I am confused...please help me!!! :-(*/
import java.awt.*;
import java.awt.geom.*;
public class MyFrame extends Frame{
MyFrame(){
setSize(400,400);
setVisible(true);
}
public static void main(
String[]args){
new MyFrame();
}
public void paint(Graphics g){
Graphics2D g2D=(Graphics2D)g;
g2D.setStroke(new BasicStroke(3.0f));
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
Line2D.Double line=new Line2D.Double(0,0,0,50);
AffineTransform at=new AffineTransform();
at.translate(200,200);
for(int i=0;
{
g2D.setPaint(Color.black);
at.rotate(Math.toRadians(6));
g2D.setTransform(at);
g2D.draw(line);
if((i+=6)==360)
i=0;
try{
Thread.sleep(1000);
}catch(InterruptedException e){}
g2D.setPaint(Color.white);
g2D.fillRect(0,0,getWidth(),getHeight());
}
}
}