Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

showConfirmDialog question

Status
Not open for further replies.

ob1kanobee

Programmer
Dec 27, 2002
47
US
How do I get this message dialog box to appear in the front of the screen.

I am using it in a java class function that is called by another class, so when I pass null as the parent component, it is showing up behind the webpage calling the class function.

result = jOpt.showConfirmDialog(null,sMsg,"Invalid File Extension",jOpt.YES_NO_OPTION);
 
No, the component calls a class function which then makes reference to this class function. Parent-component will not work.
I guess I'm looking for something the equivalent of App.ActiveForm in VB or some windows API that can return what the active window is.
I worked around it by creating a frame that contains this message box, then centered the frame on the user's screen and gave it focus by using the .toFront method.
I'm not happy about exposing an additional frame just to have a component to latch onto.
 
What about propagating a reference to the parent container?

Cheers,

Dian
 
I created a small app to test this and had no such problem.

Is it possible that the class method that loads the JOptionPane is working in a separate thread from the parent container?

If so , then the parent container would not block on the JOptionPane, but would repaint itself, thereby covering the message up.

 
Thanks for the responses. idarke, you may be right about repainting itself.

The function basically checks the file you are about to upload for Unknown file extensions and is called by a Manager class add method. If user decides to override it and upload the file anyway, then the add method continues with the add and returns to the calling jsp, otherwise it exits the add function returns to the calling jsp.

The first time the function is called, the JOptionPane appears in the background. If I were to reload any file again within the same jsp, it then appears in the foreground as it should and also from then on until I revisit another jsp that has a file upload event.

I'm guessing that the first time around, it has not established a parent-container. Not sure.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top