import javax.swing.*;
/**
 * A subclass of JFrame that can be resized in
 * several different ways.
 */
public class ResizingWindow extends JFrame {
 
  /** subtract dW from this window's width,
   *  and subtract dH from this window's height.
   */
  public void shrink(int dW, int dH) {
    // equivalent to prepending "this"
    // to each method
    setSize(getWidth() - dW, getHeight() - dH);
  }
  
  /**
   * change the width and height by proportion p,
   * a double.  p > 1 increases the size,
   * 0<= p < 1 decreases the size.
   */
  public void resize(double p) {
    setSize((int)(p*getWidth()),
            (int)(p*getHeight()));
  }
 
  /**
   * return this window's area, width times height
   */
  public int getArea() {
    return getWidth() * getHeight();
  }
}