关于paint 和paintComponents问题
高手帮帮忙,程序如下:import java.awt.*;
import java.awt.geom.*;
public class testLine extends Panel
{
int x,y;
public void paint(Graphics g) //如果我用成paintComponents就不行了,所以我请问一下,这两个方法有什么分别? 应该注意什么
{
y=x=50;
Graphics2D gr=(Graphics2D)g;
for(int t=0;t<=10;t++)
{
gr.draw(new Line2D.Double(x,y+t*30,x+300,y+t*30));
gr.draw(new Line2D.Double(x+t*30,y,x+t*30,y+300));
System.out.println("Hello");
}
}
public static void main(String[] args)
{
testLine testline = new testLine();
Frame f=new Frame();
f.add(testline);
f.setSize(400,400);
f.show();
}
}