Java Reference
In-Depth Information
13 CarComponent component = new
CarComponent();
14 frame.add(component);
15
16 frame.setVisible(true);
17 }
18 }
S ELF C HECK
18. Which class needs to be modified to have the two cars positioned next to
each other?
19. Which class needs to be modified to have the car tires painted in black,
and what modification do you need to make?
20. How do you make the cars twice as big?
116
117
H OW T O 3.2: Drawing Graphical Shapes
You can write programs that display a wide variety of graphical shapes. These
instructions give you a step-by-step procedure for decomposing a drawing into
parts and implementing a program that produces the drawing.
Step 1 Determine the shapes that you need for the drawing.
You can use the following shapes:
ȗ Squares and rectangles
ȗ Circles and ellipses
ȗ Lines
The outlines of these shapes can be drawn in any color, and you can fill the insides
of these shapes with any color. You can also use text to label parts of your drawing.
Some national flag designs consist of three equally wide sections of different
colors, side by side:
Search WWH ::




Custom Search