// This appears in Core Web Programming from
// Prentice Hall Publishers, and may be freely used
// or adapted. 1997 Marty Hall, hall@apl.jhu.edu.

public class SomeComponent extends SomeOtherComponent {
  ...
  private Frame frame = null;
  
  private Frame getFrame() {
    if (frame == null) {
      Container containingWin = getParent();
      while (containingWin != null) {
        if (containingWin instanceof Frame) {
          frame = (Frame)containingWin;
          break;
        } else
          containingWin = containingWin.getParent();
      }
    }
    return(frame);
  }
}

