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

public class RectanglePanel extends JPanel {
  private static final int PANEL_WIDTH = 300;
  private static final int PANEL_HEIGHT = 300;
  // x, y, width, height
  private Rectangle mBox = new Rectangle(100, 100, 20, 30);

  public RectanglePanel() {
    setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
  }

  public void setCoordinates(Point coords) {
    mBox.setLocation(coords.x, coords.y);
    repaint();
  }

  public void paintComponent(Graphics g) {
    // first let the superclass erase the old contents
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D)g;
    g2.draw(mBox); // now draw our box
  }
} // end RectanglePanel




