title: How to enlarge/move polygon in Java?
body: <p>So I have the following code:</p>
  
  <pre><code>import java.awt.*;
  
  public class Triangle extends Point {
      protected int size;
      private int p1x, p2x, p3x, p1y, p2y, p3y;
  
      //Create a new triangle
      public Triangle()
      {
          super();
          size = 100;
          yPos = 100;
      }
  
  
      public void reSize(int newSize) {
          size = size + newSize;
      }
  
      //Draw the triangle with current specifications on screen.
      public void display(Graphics g) {
          p1x = (size / 3);
          p2x = (size / 2);
          p3x = ((2 * size) / 3);
          p1y = ((2 * size) / 3);
          p2y = (size / 3);
          p3y = ((2 * size) / 3);
          int[] xPoints = { p1x, p2x, p3x };
          int[] yPoints = { p1y, p2y, p3y };
          int npoints = 3;
          g.fillPolygon(xPoints, yPoints, npoints);
      }
  }
  </code></pre>
  
  <p>And the following code is used to enlarge/reduce the triangle:</p>
  
  <pre><code>    if (e.getSource() == makeBigger) {
            aShape.reSize(20);
      }
  
      else if (e.getSource() == makeSmaller) {
            aShape.reSize(-20);
      }
  </code></pre>
  
  <p>The problem is, I also want the ability to drag it using the following code:</p>
  
  <pre><code>    this.addMouseListener(new MouseAdapter() {
      public void mouseReleased(MouseEvent me) {
          shapeColor = Color.black;
          repaint();
      }
  
      public void mouseDragged(MouseEvent me) {
          shapeColor = Color.lightGray;
          aShape.moveXY(me.getX(), me.getY());
          repaint();
      }
  });
  
      this.addMouseMotionListener(new MouseAdapter() {
      public void mouseReleased(MouseEvent me) {
          shapeColor = Color.black;
          repaint();
      }
  
      public void mouseDragged(MouseEvent me) {
          shapeColor = Color.lightGray;
          aShape.moveXY(me.getX(), me.getY());
          repaint();
      }
  });
  </code></pre>
  
  <p>And the only way I can see it is that I can have either one or the other. How do I combine it so I can have both features? At the moment it resizes perfectly, but say I change the variablle size in the x/y coordinates to yPos/xPos I'll be able to drag the triangle but not reshape it.</p>
  
  <p>Thanks!</p>