public abstract void drawOval(int x, int y, int width, int height)
x
、y
、width
和 height
参数指定的矩形(指的是外接矩形)中。 椭圆覆盖区域的宽度为 width + 1
像素,高度为 height + 1
像素。
x
- 要绘制椭圆的左上角的 x 坐标。 y
- 要绘制椭圆的左上角的 y 坐标。 width
- 要绘制椭圆的宽度。 height
- 要绘制椭圆的高度。1、编写applet程序1,在屏幕上画一组同心圆,相邻两圆的直径大小相差10(pixel);
import java.applet.*;
import java.awt.Color;
import java.awt.Graphics;
import java.util.Random;
public class AppletCircle extends Applet {
public void init() {
this.setSize(400, 400);
}
public void paint(Graphics g) {
Color color ;
for (int i=0; i<20; i++){
color = new Color((int)(Math.random()*256),(int)(Math.random()*256),(int)(Math.random()*256));
g.setColor(color);
g.drawOval(20+5*i, 30+5*i, 300-10*i, 300-10*i);
}
}
public static void main(String[] args){
new AppletCircle();
}
}
联系客服