Java Reference
In-Depth Information
FIGURE 9.5: Picture for Exercise 2.
9.8 Lab
Create an application that displays a number of shapes (including lines, rectangles,
circles, and ellipses) in a window. The type of shape to be displayed should be chosen at
random. The color of the shape and whether or not to fill the shape (if it can be filled) should
also be chosen at random. Make sure that the content of the window does not change as you
resize or restore the window. For this purpose, you can create a class called MyShape that can
draw each of the shapes (should store the type of shape, color of the shape, coordinates of
shape, etc.). Also, save an ArrayList of shapes in the MyPanel class. The paintComponent
method in the MyPanel class should simply draw all the shapes from the ArrayList .The
paintComponent method should not generate any of the data.
 
Search WWH ::




Custom Search