import javax.swing.*;
import java.util.Date;
/**
 * A customized JFrame that can double its width.
 * And does some other clever tricks.
 */
public class DoubleWidthWindow extends JFrame {
  
  /**
   * This window's date
   */
  private Date date;
  
  /**
   * a subwindow of this window
   */
  private DoubleWidthWindow sw;
  
  /**
   * Set this window's date to d.  Then set this
   * window's title to d.toString()
   */
  public void setDate(Date d) {
    this.date= d;
    setTitle(d.toString());
  }
  
  
  /**
   * = this window's date
   */
  public Date getDate() {
    return this.date;
  }
  
  /**
   * Double the width of this window
   */
  public void doubleWidth() {
    // scope of a variable is the part of your
    // code where it is accessible.  A local variable
    // has scope of the method where it is declared.
    
    // w is a local variable for a DoubleWidthWindow
    // so the memory allocated to w is reallocated
    // at the end of this method
    DoubleWidthWindow w;
    w= new DoubleWidthWindow();
    sw= new DoubleWidthWindow();
    sw.setSize(getWidth(), getHeight());
    sw.setTitle("Subwindow");
    w.setSize(this.getWidth(), this.getHeight());
    w.show();
    sw.show();
    this.setSize(2*this.getWidth(), getHeight());
  }
  
    /**
     * "third" the width of this window
     */
    public void thirdWidth() {
      setSize(getWidth()/3, getHeight());
    }
    
    /**
     * set the location to the size
     */
    public void setLocationToSize() {
      setLocation(getWidth(), getHeight());
    }
    
    /** Multiply the width of this window by a
     * parameter i
     */
    public void multiplyWidth(int i) {
      setSize(i*getWidth(), getHeight());
    }
    
    /**
     * is the width greater than 500
     */
    public boolean widthGreaterThan500 () {
      return getWidth() > 500;
    }

}