FileDialog Parent
Creation of a FileDialog requires a Frame parent. If this is done from an overridden MenuButton then the Frame has to be found by walking up the parent tree from the MenuButton:
class OpenButton extends MenuButton {
public boolean action(Event evt, Object what) {
Object parent = evt.target;
while (parent != null &&
!(parent instanceof Frame)) {
parent = ((MenuComponent)
parent).getParent();
}
new FileDialog((Frame) parent,
"Open File");
}
}