小问题
import java.awt.*;import java.awt.geom.*;
import java.util.*;
import javax.swing.*;
class Snake extends Frame
{
Vector snakelength=new Vector(1);
int i;
Snake()
{
this.setSize(300,300);
this.show();
}
public void paint(Graphics g)
{
Graphics2D g2=(Graphics2D)g;
float x=0,y=0;
for(i=0;i<5;i++)
{
snakelength.addElement(new Rectangle2D.Float(x,y,10,10));
g2.draw((Rectangle2D.Float)snakelength.elementAt(i));
x+=10;
//y+=10;
}
//g2.draw((Rectangle2D.Float)snakelength.elementAt(i));
}
}
public class SnakeMain
{
public static void main(String args[])
{
Snake snake=new Snake();
}
}
为什么只有把x,y调大些,才能看到图,x,y不是左上角的坐标点吗?
----------------解决方案--------------------------------------------------------