📄 bullseye.java
字号:
//********************************************************************
// Bullseye.java Author: Lewis/Loftus
//
// Demonstrates the use of conditionals and loops to guide drawing.
//********************************************************************
import java.applet.Applet;
import java.awt.*;
public class Bullseye extends Applet
{
//-----------------------------------------------------------------
// Paints a bullseye target.
//-----------------------------------------------------------------
public void paint (Graphics page)
{
final int MAX_WIDTH = 300, NUM_RINGS = 5, RING_WIDTH = 25;
int x = 0, y = 0, diameter;
setBackground (Color.cyan);
diameter = MAX_WIDTH;
page.setColor (Color.white);
for (int count = 0; count < NUM_RINGS; count++)
{
if (page.getColor() == Color.black) // alternate colors
page.setColor (Color.white);
else
page.setColor (Color.black);
page.fillOval (x, y, diameter, diameter);
diameter -= (2 * RING_WIDTH);
x += RING_WIDTH;
y += RING_WIDTH;
}
// Draw the red bullseye in the center
page.setColor (Color.red);
page.fillOval (x, y, diameter, diameter);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -