package cn.test.circle;
import java.awt.Color;
import java.awt.Graphics;
public class MyCircle {
private int x ;
private int y ;
private int w ;
private int h ;
public MyCircle(int x, int y, int w, int h) {
super();
this.x = x;
this.y = y;
this.w = w;
this.h = h;
new MyCircleThread().start();
}
public void drawMe(Graphics g){
g.setColor(Color.red);
g.drawOval(x, y, w, h);
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public int getW() {
return w;
}
public void setW(int w) {
this.w = w;
}
public int getH() {
return h;
}
public void setH(int h) {
this.h = h;
}
private class MyCircleThread extends Thread{
@Override
public void run() {
super.run();
while(true){
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//不断改变属性值
x = (int)(Math.random()*100);
y = (int)(Math.random()*100);
w = (int)(Math.random()*100);
h = (int)(Math.random()*100);
System.out.println("圆的内部在刷新坐标"+x+"--"+y+"---"+w+"---"+h);
}
}
}
}