Dialogs always on the top


S

Sameer

The dialogs created with JOptionPane are modal dialogs
and each showXxxDialog method of JOptionPane blocks the
current thread until the user's interaction is complete.

But how to make them to be always on top of the owner?

I have got a problem related to this functionality:

In my Chat Application the owner of a dialog is a frame.
Suppose that the close button of the frame initiates a dialog and
when this dialog is active, another event happens which let the
frame got the focus, in this situation, the dialog disappers (goes
behind the frame) and frame was not in a position to receive any
input though it has focus.

Please suggest remedy for the same.
-Sameer
 
Ad

Advertisements

J

jan V

Please suggest remedy for the same.

Before your program pops up the dialog, broadcast an event to all your
focus-able components that they should refuse the focus. If that scheme
doesn't work, find another way of basically making it impossible for the
focus to leave your dialog.
 
B

Babu Kalakrishnan

Sameer said:
The dialogs created with JOptionPane are modal dialogs
and each showXxxDialog method of JOptionPane blocks the
current thread until the user's interaction is complete.

But how to make them to be always on top of the owner?

I have got a problem related to this functionality:

In my Chat Application the owner of a dialog is a frame.
Suppose that the close button of the frame initiates a dialog and
when this dialog is active, another event happens which let the
frame got the focus, in this situation, the dialog disappers (goes
behind the frame) and frame was not in a position to receive any
input though it has focus.

Please suggest remedy for the same.

Are you sure you're setting the parent component for the JOptionPane
correctly ? As far as I can recall, if you set the parent correctly, the
dialog does stay on top of the parent.

BK
 
S

Sameer

Sorry sir, but i observed that my the JOptionPane.showXX .... method
was wrapped in another method which is passing 'null' as the
parameter for the Component and not the parent and that's why it may be
not working.
 
Ad

Advertisements

B

Babu Kalakrishnan

Sameer said:
Sorry sir, but i observed that my the JOptionPane.showXX .... method
was wrapped in another method which is passing 'null' as the
parameter for the Component and not the parent and that's why it may be
not working.

The certainly would be the cause. The "component" parameter of the
showXX is the one from which the shown dialog's parent is derived - The
parent would be set as the Top level window in which the specified
component is located.

BK
 

Top