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
 
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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top