JAVA编程!
编写一个Applet在屏幕中画一组同心圆,其中两个圆的直径大小相差10,Applet的大小为300*300。...
编写一个Applet在屏幕中画一组同心圆,其中两个圆的直径大小相差10,Applet的大小为300*300。
展开
1个回答
展开全部
import java.applet.Applet;
import java.awt.Graphics;
public class TestApplet extends Applet{
static final int WIDTH = 300;
static final int HEIGHT = 300;
static final int RAD = 10;
public void paint(Graphics g) {
this.setSize(WIDTH, HEIGHT);
g.drawOval(0, 0, WIDTH, HEIGHT);
g.drawOval(RAD/2, RAD/2, WIDTH-RAD, HEIGHT-RAD);
}
public void setSize(int width, int height) {
super.setSize(width, height);
}
}
import java.awt.Graphics;
public class TestApplet extends Applet{
static final int WIDTH = 300;
static final int HEIGHT = 300;
static final int RAD = 10;
public void paint(Graphics g) {
this.setSize(WIDTH, HEIGHT);
g.drawOval(0, 0, WIDTH, HEIGHT);
g.drawOval(RAD/2, RAD/2, WIDTH-RAD, HEIGHT-RAD);
}
public void setSize(int width, int height) {
super.setSize(width, height);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询