In code I am calling repaint()
method from init()
method but Output is not as per I expect.
I called repaint()
method 10 times but It called paint()
only once(See Screenshot of O/P).
Am I making any mistake. please help me.
Thanks
code
import java.awt.*;
import java.applet.Applet;
/*
<applet code="test" height=300 width=300>
</applet>
*/
public class test extends Applet
{
int x,y;
public void init()
{
x=5;
y=10;
for(int i=1;i<10;i++)
{
System.out.println("From init "+i);
x+=(i*2);
y+=(i*3);
repaint();
}
}
public void paint(Graphics g)
{
System.out.println("Paint");
g.drawLine(50,50,x,y);
}
}