void addShape(Shape shape) {
   // Add the shape to the canvas, and set its size/position and color.
   // The shape is added at the top-left corner, with size 80-by-50.
   // Then redraw the canvas to show the newly added shape.
   shape.setColor(currentColor);
   shape.reshape(3, 3, 80, 50);
   shapes.add(shape);
   repaint();
 }
Exemplo n.º 2
0
 /**
  * On click, if a shape has been clicked, change its color to the Drawing object's current set
  * color.
  */
 public void executeClick(Point p, Drawing dwg) {
   Shape clickedShape = dwg.getFrontmostContainer(p);
   if (clickedShape != null) clickedShape.setColor(dwg.getColor());
 }