为什么显示两次

不知道为什么会显示两次

import java.awt.*;
import java.awt.geom.Ellipse2D;
import java.net.URL;
public class UseClip extends Frame{
Graphics2D g2;
Image img;
Toolkit tk;
Mys m=new Mys();
public UseClip(String title) throws Exception{
super(title);
setVisible(true);
setSize(500,500);
tk=getToolkit();
img=tk.getImage(new URL("http://fs01.bokee.net/userfilespace/2007/07/10/wangyongfu574577_s.jpg"));
tk.prepareImage(img,-1,-1,this);
}//end gouzao
public void paint(Graphics g){
g2=(Graphics2D)g;
for(int i=60;i<=150;i++){
g2.setClip(new Ellipse2D.Double(50,50,i,i));
try {
m.sleep(100);
} catch (InterruptedException e) {
//e.printStackTrace();
}
g2.drawImage(img,60,60,this);
}
}

public static void main(String[] args) throws Exception {
UseClip f=new UseClip("使用Clip属性形成遮罩效果");

}

}

class Mys extends Thread{
public Mys() throws InterruptedException{
this.sleep(1000);
}
}

你可能感兴趣的:(显示)