[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
|
- From: Magnus Konze <bodomchild@xxxxxx>
- Date: Thu, 20 Mar 2008 14:37:28 +0100
- Newsgroups: eclipse.platform.swt
- Organization: EclipseCorner
- User-agent: Thunderbird 2.0.0.0 (Windows/20070326)
Hi,
thanks for your answer.
I already tried to open a invisible (= 0-sized) modal AWT dialog, but
the titlebar can't be resized to 0.
Here is my current workaround:
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import org.eclipse.jface.dialogs.Dialog;
public class BlockableFrame extends JFrame {
private Dialog dialog;
public BlockableFrame() {
addWindowListener(new WindowAdapter() {
public void windowActivated(WindowEvent e) {
if (dialog != null) {
dialog.getShell().getDisplay().syncExec(new Runnable() {
public void run() {
dialog.getShell().forceFocus();
}
});
}
}
});
}
public void setModalSWTDialog(Dialog dialog) {
this.dialog = dialog;
setEnabled(false);
}
public void removeModalSWTDialog() {
this.dialog = null;
setEnabled(true);
toFront();
}
}
My Swing frames have to extend BlockableFrame. When i open a SWT dialog
setModalSWTDialog() disables the frame. After setting the dialog the
WindowListener forwards the focus to the dialog, if you click on the
applications button on the taskbar. After closing the dialog you have to
remove the reference with removeModalSWTDialog().
I dont't know, if this is a great solution, but it works and it is only
a temporary solution.
Regards Magnus