關於圓的圓周的問題。爲了改變圓(周長)的色彩外,我會用使用arcAngle着色圓的外側
drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
只是不正是如何將下面的代碼below..after Public void drawArc
我不知道以後開始去哪裏
public void paintComponent(Graphics g) {
super.paintComponent(g);
Dimension d = getSize();
for(int i = 0; i < 100; ++i) {
Color color = new Color(generator.nextInt(255), generator.nextInt(255), generator.nextInt(255));
g.setColor(color);
int circleSize = generator.nextInt(d.width/4);
int x = generator.nextInt(d.width - circleSize);
int y = generator.nextInt(d.height - circleSize);
g.fillOval(x, y, circleSize, circleSize);
g.drawArc(x, y, circleSize, circleSize, 0, 360);
}
}
您是否有可能誤解您的任務?我認爲你的老師希望你使用'Graphics'類的'drawArc'方法,而不是寫你自己的。 –
@DavidWallace我同意,這是我改變了它,但現在我又被卡住了.. –
@DavidWallace添加聲明來改變顏色做了工作謝謝! –