posted 15 years ago
Hi, I am not understanding how to draw my custom components onto a panel. My teacher is asking for an abstract class, Shape, which cannot extend or implement anything. Then I have two subclasses, Circle and Square, that extend Shape (so they cannot extend anything else like JComponent). Finally I have a class, Draw, that creates a main window and adds three buttons. One button adds Circle objects, one button adds Square objects, and the other button changes the colors of the objects. Currently, when I click "Add Circle," I get runtime exceptions. Can anyone help me understand why? Here's my source:
Shape.java
Circle.java
Draw.java
Sorry there's so much code... I have a feeling it has something to do with the way I'm handling the event in the actionPerformed method (right at the bottom of Draw.java). Thanks for any help!