Java Reference
In-Depth Information
private final static long serialVersionUID = 1001L;
}
// Abstract methods & fields in Element class...
}
Directory "Sketcher 5 drawing sketch circle elements"
You can't use the base class constructor that requires two arguments because you have to calculate the
position for a circle first. A base class constructor call must appear as the first statement in the body of
the derived class constructor. Add the following constructor to the Element class:
protected Element(Color color) {
this.color = color;
}
Directory "Sketcher 5 drawing sketch circle elements"
This just initializes the color member.
If you amend the createElement() method in the MouseHandler class by uncommenting the line that
creates Element.Circle objects and recompile the Sketcher program, you are ready to draw circles. You
are now equipped to produce artwork of the astonishing sophistication shown in Figure 19-27 .
FIGURE 19-27
 
 
Search WWH ::




Custom Search