【发布时间】:2015-09-13 23:51:26
【问题描述】:
我是新来的。我正在尝试在 javaApplet 中绘制一个圆圈,但不知何故在输出中它显示了 3 个圆圈。任何的想法?
import javax.swing.JApplet;
import java.util.*;
import java.awt.*;
public class Shapes extends JApplet
{
public void paint (Graphics page)
{
resize(400,300);
Random rand = new Random();
// Declare size constants
final int circleMax = 160,circleMin = 40; // circle max and min diameter
final int locMaxX = 360, locMaxY = 260;
int radiusSize = 0, locationx = 0,locationy = 0 ;
// Declare variables
radiusSize = (rand.nextInt(circleMax)+ circleMin);
locationx =20 ;//rand.nextInt(locMaxX)+ 20;
locationy =20 ;// rand.nextInt(locMaxY) + 20;
// Draw the circle 1
page.drawOval(locationx, locationy, radiusSize,radiusSize);
}
}
【问题讨论】: