We have a problem where the most elegant solution would be to implement a modal dialog from within our applet while running under a browser. In brief, a user enters an html page, and to fill in some of the fields on that html page, we pop open a modal search window, and then put the information into the relevant field.
The problem is, of course, that while modal dialogs behave modally under appletviewer and hotjava, both Netscape and Microsofts's implementations do not behave as advertised.
I'm sure that someone has spent a good six months banging their head against a keyboard figuring this one out. Rather than reinvent the wheel, I thought maybe some of you might be kind enough to share a better way.
> We have a problem where the most elegant solution would be to > implement a modal dialog from within our applet while running under a > browser. In brief, a user enters an html page, and to fill in some of > the fields on that html page, we pop open a modal search window, and > then put the information into the relevant field.
> The problem is, of course, that while modal dialogs behave modally > under appletviewer and hotjava, both Netscape and Microsofts's > implementations do not behave as advertised.
> I'm sure that someone has spent a good six months banging their head > against a keyboard figuring this one out. Rather than reinvent the > wheel, I thought maybe some of you might be kind enough to share a > better way.
We had to deal with the same Problem. What happens is that the execution of the code is 'modal'. However the Applet is still enabled for Events and handles them.
What we did was somthing like this:
void launchModalDialog() { this.setEnabled(false); // disable the Applet try { MyDialog myDialog = new MyDialog(this, true); myDialog.setVisible(true); //launch the Dialog } catch(Exception e) // you should do this here or // if the Dialog dies the Applet hangs... { System.err.println(e); // make shure you see the Error } this.setEnabled(true); //enable the Applet again
}
Didn't like that very much. But it worked most of the time.
If you are using the 1.1 event model, you can register a listener to your dialog that monitors if it loses focus, and if so, reclaims it. I haven't managed to use the regular dialog modal feature on an applet at all )=
If you want to use dialogs in an applet, you have to iterate the applets getParent() until it is an instance of Frame, and use that as a part of your instatiation.
Then just create a class that extends Dialog and listens for focusLost().
>We have a problem where the most elegant solution would be to >implement a modal dialog from within our applet while running under a >browser. In brief, a user enters an html page, and to fill in some of >the fields on that html page, we pop open a modal search window, and >then put the information into the relevant field.
>The problem is, of course, that while modal dialogs behave modally >under appletviewer and hotjava, both Netscape and Microsofts's >implementations do not behave as advertised.
>I'm sure that someone has spent a good six months banging their head >against a keyboard figuring this one out. Rather than reinvent the >wheel, I thought maybe some of you might be kind enough to share a >better way.