import java.awt.Frame;
import java.awt.Graphics;
public class S extends Frame{
private int x;
private int y;
private boolean drawOval;//为true时绘制
//测试入口函数
public static void main(String []args)
{
new S().print();
}
//构造函数,初始化x、y坐标,设置drawOval变量为false,设置窗体大小
public S()
{
x = 200;
y = 200;
drawOval = false;
this.setSize(400,400);
this.setVisible(true);
}
public void print(){
//在调用S类实例的print方法时,画一个以属性X,Y为起点的宽高为10的圆.
drawOval = true; //设置drawOval变量为true
repaint(); //调用刷新画面方法
}
public void paint(Graphics g)
{
//为true时绘制
if(drawOval)g.fillOval(x,y,10,10);
}
}