Tom Kelliher, CS 116
Sept. 20, 2000
Read 3.1--2.
Lab 2.
Introduction to widgets.
drawHole():
private void drawHole(int n, Graphics g)
{
int X0 = 50, // x-anchor
Y0 = 50, // y-anchor
W0 = 350, // initial width
H0 = 200, // initial height
X_INC = 30, // x-anchor increment
Y_INC = 10, // y-anchor increment
RG_INC = 10, // red-green increment
BLUE_INC = 25; // blue increment
g.setColor(new Color(n * RG_INC,
n * RG_INC,
(n + 1) * BLUE_INC));
g.fillOval(X0 + n * X_INC, Y0 + n * Y_INC,
W0 - n * X_INC, H0 - n * 2 * Y_INC);
}
Color
constructor.
Remember: the computer knows nothing. It cannot figure out what you want to occur. You must instruct it, step by step.
java.awt.Graphics class
description in Section 2.8.
Start: applet not initializedExit AppletViewer and in JWS do the following: Open the Project menu, choose Properties, and look at the Run tab. Check that the Main Class Name entry matches your class name, including capitalization.
Working in your lab groups, design a Java Method to produce a shaded ball like this:

Use the following signature for your method:
void drawBall(Graphics g, int x, int y, int radius)where
x and y are the center of the largest circle.