I'm trying to display a modal dialog in front of an Applet
.
My current solution fetches the root frame like so:
Frame getMyParent() {
Container parent = getParent();
while (!(parent instanceof Frame)) {
parent = ((Component)parent).getParent();
}
return (Frame)parent;
}
And creates the dialog as follows:
public OptionsDialog(MainApplet applet, boolean modal) {
super(applet.getMyParent(), "options", modal);
// ....
However often this shows the modal dialog below the frame, though the modal behaviour works correctly.
How can this be fixed?
EDIT: I should have clarified before, for Java versions 1.5 and above.