FileDialog Parent

Creation of a FileDialog requires a Frame parent. If this is done from a Button then the Frame has to be found by walking up the parent tree from the Button:

class OpenButton extends Button {
   public boolean action(Event evt, Object what) {
      Object fr = evt.target;

      while (fr != null && 
             !(fr instanceof Frame))
         fr = ((Component) 
                    fr).getParent();
      new FileDialog((Frame) fr, "Open");
   }
}


Slide 61