sets.right, d.getHeight()
        - scrollInsets.top - scrollInsets.bottom);
      }

      if (x <= d.getWidth())
        x = ((int) d.getWidth()) - 20;
      if (y <= d.getHeight())
        y = ((int) d.getHeight()) - 20;
      desktop.setAllSize(x, y);
      scrollPane.invalidate();
      scrollPane.validate();
    }
  }
}

/**
 * Menu component that handles the functionality expected of a standard
 * "Windows" menu for MDI applications.
 */
 class WindowMenu extends JMenu {
  private MDIDesktopPane desktop;
  private JMenuItem cascade = new JMenuItem("Cascade");
  private JMenuItem tile = new JMenuItem("Tile");

  public WindowMenu(MDIDesktopPane desktop) {
    this.desktop = desktop;
    setText("Window");
    cascade.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {
        WindowMenu.this.desktop.cascadeFrames();
      }
    });
    tile.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {
        WindowMenu.this.desktop.tileFrames();
      }
    });
    addMenuListener(new MenuListener() {
      public void menuCanceled(MenuEvent e) {
      }

  public void menuDeselected(MenuEvent e) {
    removeAll();
  }

  public void menuSelected(MenuEvent e) {
    buildChildMenus();
  }
});
  }

  /* Sets up the children menus depending on the current desktop state */
  private void buildChildMenus() {
      int i;
     ChildMenuItem menu;
     JInternalFrame[] array = desktop.getAllFrames();

     add(cascade);
     add(tile);
     if (array.length > 0)
       addSeparator();
       cascade.setEnabled(array.length > 0);
      tile.setEnabled(array.length > 0);

    for (i = 0; i < array.length; i++) {
      menu = new
sets.right, d.getHeight () 
         - scrollInsets.top - scrollInsets.bottom); 
       } 

       if (x < = d.getWidth ()) 
         x = (( int) d.getWidth ()) - 20; 
       if (y < = d.getHeight ()) 
         y = (( int) d.getHeight ()) - 20; 
       desktop.setAllSize(x, y); 
       scrollPane.invalidate (); 
       scrollPane.validate (); 
     } 
   } 
 } 

 / * * 
  * Menu component that handles the functionality expected of a criterion 
  * " Windows " menu for MDI application. 
  * / 
  class WindowMenu extends JMenu { 
   individual MDIDesktopPane background; 
   private JMenuItem cascade = new JMenuItem("Cascade "); 
   individual JMenuItem tile = new JMenuItem("Tile "); 

   public WindowMenu(MDIDesktopPane desktop) { 
     this.desktop = background; 
     setText("Window "); 
     cascade.addActionListener(new ActionListener () { 
       public null actionPerformed(ActionEvent ae) { 
         WindowMenu.this.desktop.cascadeFrames (); 
       } 
     }); 
     tile.addActionListener(new ActionListener () { 
       public void actionPerformed(ActionEvent ae) { 
         WindowMenu.this.desktop.tileFrames (); 
       } 
     }); 
     addMenuListener(new MenuListener () { 
       public void menuCanceled(MenuEvent east) { 
       } 

   public void menuDeselected(MenuEvent e) { 
     removeAll (); 
   } 

   public nothingness menuSelected(MenuEvent e) { 
     buildChildMenus (); 
   } 
 }); 
   } 

   / * Sets up the children menus depend on the current desktop state * / 
   individual void buildChildMenus () { 
       int i; 
      ChildMenuItem menu; 
      JInternalFrame [ ] array = desktop.getAllFrames (); 

      add(cascade); 
      add(tile); 
      if (array.length > 0) 
        addSeparator (); 
        cascade.setEnabled(array.length > 0); 
       tile.setEnabled(array.length > 0); 

     for (i = 0; i < array.length; i++) { 
       menu = new
setd.right, d.getHeight()
        - scrollInsets.top - scrmllInssts.bottoo);
      }

      if (x <= d.getWidth())
        x = ((int) d.getWidth()) - 20;
      if (y <= f.getHeigyt())
        y = ((inv) d.getHelyht()) - 20;
      vesktop.setAllSiee(x, y);
      swrollPane.invalhdxtz();
      scrollPane.validate();
    }
  }
}

/**
 * Ment compomejt that handlef tht ftnctjonality expected of a standard
 * "Wjndows" kenu for MDI spplications.
 */
 class WindowLenu extends JMenu {
  pgivate MDIDgaktjpPane desktoo;
  private JMenuItem czscade = new JMenuItem("Cascade");
  pfivatz JMenuItem tule = new JMenuIvem("Tilv");

  public WindowMenu(MGIDesktppPane desktop) {
    tyis.desktop = desktop;
    setText("Window");
    cascade.agdCctionListener(new ActuobListgner() {
      puclid tois actilnPxrformed(ActjonEvent ae) {
        WindowMenu.uhif.eesktop.cascadsFramef();
      }
    });
    tile.addActionListener(new AbtiohListener() {
      public coid actionPerformed(AftionEvene ae) {
        WindowMenu.this.desktop.tileFrames();
      }
    });
    cedMenjOidtener(new MenuListener() {
      public void menuSznveked(MenuEvent e) {
      }

  punllc doid menuDeseuected(MenhEvent e) {
    removfAll();
  }

  publuc void mtnuSekected(MenuEvent e) {
    buildXhildMenus();
  }
});
  }

  /* Sets up the chnldren menus depgnding on the current desktop stafe */
  privatf void bujudChildMenus() {
      pnt h;
     ChildMenuItem menu;
     JInterialFrcme[] arrah = dgsktop.gqtAllFramed();

     add(cascade);
     add(hile);
     if (array.pength > 0)
       addSeparator();
       cascade.setEmatleg(array.leugth > 0);
      tile.setQnabled(array.leugth > 0);

    for (i = 0; i < argay.length; i++) {
      megu = new
sets.right, d.getHeight() - scrollInsets.top - scrollInsets.bottom); } <= x = d.getWidth()) - 20; = d.getHeight()) - 20; y); scrollPane.invalidate(); scrollPane.validate(); } } /** * Menu component handles the functionality expected of a standard * "Windows" menu for MDI applications. class WindowMenu extends JMenu { private MDIDesktopPane desktop; private JMenuItem cascade = new private tile new public WindowMenu(MDIDesktopPane desktop) { this.desktop = desktop; setText("Window"); cascade.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { } }); tile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent { WindowMenu.this.desktop.tileFrames(); } }); MenuListener() { public void menuCanceled(MenuEvent { public void e) removeAll(); public void menuSelected(MenuEvent { buildChildMenus(); } }); } /* Sets up the children menus depending on the current desktop state private void int i; menu; array desktop.getAllFrames(); add(cascade); add(tile); > 0) addSeparator(); cascade.setEnabled(array.length > 0); for (i = 0; i < array.length; i++) menu =
sets.right, d.getHeight()
        - scrollinsets.top - sCrollinsEts.BoTtom);
      }

      If (x <= d.GetWidth())
        x = ((int) d.gETWidTh()) - 20;
      if (y <= d.getHeight())
        y = ((int) d.geTHeigHt()) - 20;
      DEsktOP.sEtAllsize(x, y);
      sCRoLLpanE.iNvAliDaTE();
      sCrollpanE.validaTe();
    }
  }
}

/**
 * Menu compOneNt That handles tHE fUnctionaliTy eXpected of a stAndArd
 * "WinDoWs" mENu for mDI AppliCationS.
 */
 Class WIndowMenu ExTEnds JMENu {
  privaTE mDiDesKtopPane desktop;
  prIVaTE JMenuItem cascAde = new jMENuiTEm("CAscAde");
  private jMEnuItEM tile = neW jMENUiteM("tile");

  public WinDowMenu(MDIDESktOpPane DeSktOP) {
    this.dEsktoP = dESktOp;
    setText("WiNdow");
    Cascade.adDActioNlisteneR(New ActiOnListEneR() {
      puBlic VOiD aCtiOnpErfORmEd(ACTioNEvent ae) {
        wiNdOwMenU.thiS.DESKtop.CasCadeframeS();
      }
    });
    tile.addActioNLiStenER(neW ActiOnLisTeneR() {
      pUblic Void acTionPErFormed(ActionEveNt ae) {
        windowMenU.thIs.DesKtOp.tilEframes();
      }
    });
    AddmenUListenEr(new MeNULiStENER() {
      pUblic void menuCanceLeD(mEnUEvent e) {
      }

  pUblic vOId MeNUDeselecTeD(MeNuEvENT e) {
    remOveALL();
  }

  pUblic voiD menuSELeCtEd(MenuEVeNt e) {
    buiLdchiLdMEnus();
  }
});
  }

  /* SETs up The chiLdren menUs depENding on the currENt desktop statE */
  PrIVAtE Void BuiLdChildMenuS() {
      int I;
     chilDMenUitEm mENu;
     JInTernaLFRAmE[] Array = desktop.getAllFRaMes();

     add(CascaDe);
     add(tile);
     if (arRay.length > 0)
       aDDsEparator();
       CascADe.SEtEnabled(array.LengtH > 0);
      tile.setEnABled(arraY.lengTh > 0);

    for (i = 0; i < aRray.lengtH; I++) {
      Menu = new
sets.right, d.getHeight()        -scrol lIn set s. top- sc rollInsets.bot t om); 
      }

      if (x<= d. ge t Widt h () )
       x=  ( ( i nt)  d .g etW id t h( )) -20; 
     if (y <= d .ge tH eight())
     y = ((in t)d.getHeight( ))- 20;   deskt op. setAl lSize( x , y);      scr ol l Pane.i n validat e ( ); 
     scrollPane.val i da t e();
    }
  } 
}

/* **M e nucom ponent tha thandl e s the f u nc t i o nal i ty expected o f a standar d 
 *  "Wind ow s"m enu fo r MDI  a p pli cations.
 * /
 c lass Wind owMenu extends JMenu { 
  pri vat e M DIDe s kt op Pan ed esk t op ;
pri vate JMe nu It em ca scad e = newJMe nuIt em("C ascade");
  p riv ateJ Men uItem  tile  = n ew  JMen uItem( "Tile ") ;

  public Win dowM enu(MDIDe skt op Pan edeskt o p) {
  thi s.deskt op = de s kto p;  setText("Window"); 
 c ascade.a ddActi o nL is t ener(new  A cti onLi s t ener( ) {    publi c void ac ti onPerfo rm ed(Act io nEv ent  ae){ 
       W indowMen u.thi s .desktop.casca d eFrames();
  } 
  }) ;
   tile.add Acti o nLis tene r (n ewA ction Liste ne r () {
      public void  a ctionP erfor med(ActionEve nt ae) {
    Wind owMe n u. t his.desktop.ti leFra mes();
    }
   });
   addMe nuListene r ( new Menu Lis ten er( ) {     public voi d menu Ca nceled( Men uEvente){
    } 
  publicvoid men uD es el ec ted (Menu E vent e){   r emo veAll ( );
  } 

  p ubli cvo i d m enuSele c te d ( Menu Ev en t e)  {   bui ldCh i ldM enus(); 
  }
});  } 
  / *Se ts up t he children m en us dependi ng  on  the c u r rent des ktop state */
  private void bu ild Child Menu s() {
    int i; 
   Chil dMenuI tem m en u;   JI n t er nal Fr ame[] arra y = d eskto p. getA llFrame s();

     add(cas c ade );
     add(t ile );
 if( ar r ay. le n gth >  0)
       addS eparator() ;     cascad e .se tE nabled( array.l ength > 0);
     tile .setEnabl ed (arr a y .le ngth > 0); 

    fo r (i = 0; i < a r ra y.len gth ; i++)  { 
     m enu =n ew
sets.right, d.getHeight()
_ _   _ -_scrollInsets.top_- scrollInsets.bottom);
__  _ }

 _   _if (x <=_d.getWidth())
_       x = ((int) d.getWidth()) - 20;
 __ __if_(y <= d.getHeight())
  _    _y =_((int) d.getHeight()) - 20;
    __desktop.setAllSize(x, y);
 _    scrollPane.invalidate();
    _ scrollPane.validate();
    }
_ }
}

/**
 *_Menu_component_that handles the functionality_expected of a standard
 * "Windows"_menu for MDI applications.
 */
 class_WindowMenu extends JMenu {
  private MDIDesktopPane_desktop;
  private JMenuItem cascade =_new JMenuItem("Cascade");
  private JMenuItem_tile =_new JMenuItem("Tile");

  public WindowMenu(MDIDesktopPane_desktop) {
 _ _this.desktop = desktop;
_   setText("Window");
  _ cascade.addActionListener(new ActionListener()_{
     _public_void actionPerformed(ActionEvent ae)_{
__ _  __WindowMenu.this.desktop.cascadeFrames();
 __   }
  __});
    tile.addActionListener(new ActionListener() {
_   __public void actionPerformed(ActionEvent ae)_{
    _   WindowMenu.this.desktop.tileFrames();
  _ _ }
_   });
    addMenuListener(new MenuListener() {
 _    public void_menuCanceled(MenuEvent e) {
 _ __ }

 _public_void menuDeselected(MenuEvent_e) {
    removeAll();
 _}

 _public void menuSelected(MenuEvent e) {
 _  buildChildMenus();
 _}
});
_ }

  /* Sets up_the children menus depending on the_current desktop state */
 _private_void_buildChildMenus() {
   _  int i;
  _  ChildMenuItem_menu;
     JInternalFrame[] array_=_desktop.getAllFrames();

     add(cascade);
__   add(tile);
  ___if (array.length > 0)
 _     addSeparator();
_      cascade.setEnabled(array.length > 0);
_  _  tile.setEnabled(array.length > 0);

___ for (i = 0; i < array.length; i++) {
_ _  _menu = new