package abc;
import java.awt.*;
import javax.swing.*;
public class Circle99 extends JFrame {
public static void main(String[] args) {
new Circle99();
}
public Circle99() {
setSize(300,300);
setVisible(true);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);}
public void paint(Graphics g) {
g.setColor(Color.white);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.red);
g.drawString("circle99", 20, 280);
int x0 = getWidth()/2;
int y0 = getHeight()/2;
for(int r = 0;r<y0-50;r+=1) {
g.setColor(getRandomColor());
g.drawOval(x0-r, y0-r, r*2, r*2);//坐标
}
}
Color getRandomColor() {
return new Color((int)(Math.random()*255),
(int)(Math.random()*255),(int)(Math.random()*255));
}
}
修改坐标不同,圆形状不同