// AdderOfOneEnteredShape2.java

// Listener class used with window class ShapesWindow2,
// defined in ShapesWindow2.java.
//
// Adds one shape, using data obtained from the
// user via a dialog box.
//
// This version obtains ShapeOutline data from the
// user and generates a ShapeOutline object directly,
// rather than generating a complete string
// representation as an intermediate step.

import java.awt.event.*;
import javax.swing.*;

class AdderOfOneEnteredShape2 implements ActionListener
{
   private ShapesWindow2 window;
   private ShapeBoundedBuffer shapes;

   AdderOfOneEnteredShape2(ShapesWindow2 window,
                          ShapeBoundedBuffer shapes)
   {
      this.window = window;
      this.shapes = shapes;
   }  // constructor

   public void actionPerformed(ActionEvent e)
   {
      ShapeOutline shape;

      // Between two rows of asterisks below are two statements
      // obtaining shape from a dialog box of some kind.
      // Exactly one of the two statements should be uncommented.

      // ****************************************************************
      shape = ShapeInputDialog.showDialog(window);
      // shape = ShapeInputDialog2.showDialog(window);
      // ****************************************************************

      if ( shape == null )
      {
         window.repaint();
         return;
      }  // if

      shapes.add(shape);

      window.updateDisplay();
   }  // method actionPerformed
}  // class AdderOfOneEnteredShape2