[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: SWT_AWT: Open a modal SWT Dialog in a Swing application


Magnus Konze wrote:

parent is the JFrame. By calling setEnabled(false / true) i tried to simulate the modal behaviour. I'm sure, that this is ugly, but it works.

In the Albireo project (http://www.eclipse.org/albireo) we have some code to solve a similar problem: opening a modal Swing dialog.


Instead of disabling the parent, we open a 0-sized modal SWT dialog in parallel with the Swing dialog. This avoids the visual changes that happen with setEnabled on the SWT side... not sure if AWT/Swing's setEnabled involves any visual changes, but I thought I would mention it.

But there is still a problem: If i click on the applications button on the taskbar, the frame gets the focus. It's still disabled, but of course the dialog should get the focus instead of the frame.

For opening a modal Swing dialog, we had to install listeners on the SWT side to manually return the focus back to the Swing dialog when the parent shell received focus/activation. It sounds like you may need to do the same thing in your case.


BTW, Albireo should eventually support modal SWT dialogs over a Swing frame, so I'd be very interested to hear about your progress in this area.