Hello all, I am having a minor issue with displaying a "save confirmation" popup, when it is executed from the stop method of an applet. Here is the deal, I have an applet that draws a rectangular drawing based on user input (i.e. mouse clicks and arrow keystrokes). There is a save button that sends the data to a servlet that updates a database, but some times the users forget to save and leave the applet's page, so their changes are not saved. There are instances where they may not want to save the changes so I can't automatically save the drawing. Now here is my solution... I detect whether they have made any changes by setting a boolean value in certain event handlers. I then use a popup to display a JOptionPane.shoConfirmationDialog() when the applet's stop method is called (i.e. There are links to other areas of the application on the applets page which would call a different page). My problem is that sometimes the popup is not getting focus and is not displayed "ON TOP" of the browser window. I am pretty sure that its because the applet is running in its own separate thread than the browser window on the clients machine. Another issue, which is probably related to the above issue, is that even when the popup is displayed the browser still loads URL that was called before the user has clicked an option on the popup. Now my gut is telling me there is only one thing I can do to rectify the situation... make all of the links on the page part of the applet itself. That way the call to a URL can be suspended while the popup is displayed. The only problem is that the application is running in a framed window and there are menu links that would be difficult to put on the applet. Is this a valid approach or is there a better way? Here is the stop() method’s code...
Thanks in advance. Heath [ August 05, 2002: Message edited by: Heath Lilley ] [edited by Rob Ross to reduce width of post] [ August 05, 2002: Message edited by: Rob Ross ]
first, I'm not exactly sure what you mean by "popup"; are you talking about an actual pop-up menu, or do you just mean you're "popping up" a dialog? Second, if you want to display a modal dialog that is on top of all other windows, instead of passing this, pass a reference to the window that the applet is drawn into. Try passing getParent() instead. Finally, you should not be drawing any UI code during the stop() method, for the reason you gave. You are not being given the "option" to stop(), you are just being notified that your applet is being stopped, for whatever reason. You really don't want to try dialoging with the user at this point. One solution I would suggest is having some kind of preference set so that it automatically saves your changes when you leave the page; ie, deal with your user/computer dialog before the stop() call occurs, then just do whatever the user indicated was their preference. good luck!
posted 17 years ago
Rob, Thanks for the reply. The getParent() is a good idea. Well the thing is that there is a chance that they would go in and make changes and NOT want to save. I will have to figure something else out. But thanks.
posted 17 years ago
Could you hold this kitten for a sec? I need to adjust this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!