| 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 FileOpen implements ActionListener {
public void actionPerformed(ActionEvent e) {
Object fr = e.getComponent();
while (fr != null &&
!(fr instanceof Frame))
fr = ((Component)
fr).getParent();
new FileDialog((Frame) fr, "Open");
// etc
}
}
| Slide 54 | ©Copyright 1997 | Jan Newmarch |