import javax.swing.JFrame;

/**
 * OurJFrame is a customized JFrame.
 * - OurJFrame is a subclass of JFrame.
 * - JFrame is a superclass of OurJFrame.
 * 
 * - public is an access modifier.  When a class
 *   is public, then it can be used by other classes.
 * - The class name is OurJFrame. Class names should
 *   start with uppercase letters.
 * - { indicates the start of the class definition
 * - } indicates the end of the class definition
 */
public class OurJFrame extends JFrame {
  
  /** Instance variable that stores the title of OurJFrame, as a String. */
  String ourTitle;
      
  /**
   * The following is a constructor.  
   * It is invoked whenever you write "new OurJFrame(String)".
   * 
   * Creates a window with the given title,
   * with a default size 200x100,
   * and make the window visible.
   * 
   * Note: here "title" is called a parameter, not an argument.
   */
  public OurJFrame(String title) {
    this.ourTitle = title;
    this.setTitle(this.ourTitle);
    this.setSize(200, 100);
    this.setVisible(true);
  }
  
  /**
   * Returns the title of this OurJFrame, as a String.
   */
  public String getOurTitle() {
    return this.ourTitle;
  }
  
  /**
   * This method will double the width of
   * the window.
   * - void indicates that this method is a procedure
   * Note that we can implement this without using w and h.
   */
  public void doubleWidth() {    
    // get the current width of the window
    int w = this.getWidth();

    // get the current height of the window
    int h = this.getHeight();
    
    // set the width to twice the current width, no change to height
    this.setSize(w * 2, h);
  }   
    
}