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

Hi!
We are thinking about porting a _big_ Swing application to a SWT application (later parts of the application should be used with the eclipse RAP framework). Because of it's size it's not possible to do this in one step. So we are planning to port single parts (panels, dialogs and at last the main frame) to SWT and integrate them using the SWT_AWT bridge. Our first experiments appear to be promising, but at the moment i have the following problem:
I would like to open a modal SWT dialog from a Swing panel. Here is the ActionListener, which opens the dialog:


JButton button = new JButton("open SWT dialog");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
	Display.getDefault().asyncExec(new Runnable() {
		public void run() {
			EventQueue.invokeLater(new Runnable() {
				public void run() {
					parent.setEnabled(false);
				}
			});
			Shell shell = new Shell(Display.getDefault());
			SWTDialog dialog = new SWTDialog(shell);
			dialog.open();
			EventQueue.invokeLater(new Runnable() {
				public void run() {
					parent.setEnabled(true);
					parent.toFront();
				}
			});
		}
	});
}
});

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

Is there a solution for my problem?

Regards Magnus