import javax.swing.*;
/**
 * subclass of JFrame that can create a partner
 * window that overlaps the original JFrame 
 * by a specified amount.
 */
public class OverlappingWindow extends JFrame {
  
  /**
   * a partner window to overlap this one
   */
  private JFrame partnerWindow= new JFrame();
  
  /**
   * dH is the horizontal offset of the partner
   * window, dV is the horizontal offset of the
   * partner window.
   */
  private int dH, dV;
  
  /**
   * set the amount of overlap.  dH is the horizontal
   * amount (in pixels) that the partner window
   * is shifted to the right of the original window.
   * dV is the vertical amount (in pixels) that
   * the partner window is shifted down from the
   * original window.
   */
  public void setOverlap(int dH, int dV) {
    this.dH= dH;
    this.dV= dV;
  }
  
  /**
   * show the new partner window in the specified
   * location.
   */
  public void overlap() {
    partnerWindow.setSize(getSize());
    partnerWindow.setLocation(getX() + dH,
                              getY() + dV);
    partnerWindow.show();
  }
}