Showing SWT modal dialog from AWT/Swing
Using Albireo, it's easy to see how to show a Swing dialog from SWT:
private AwtEnvironment aw开发者_开发问答tEnv = AwtEnvironment.getInstance(Display.getCurrent);
...
// call from SWT thread
void showSwingMessageDialog(String msg) {
awtEnv.invokeAndBlockSwt(new Runnable() {
public void run() {
Frame parentFrame = awtEnv.createDialogParentFrame();
JOptionPane.showMessageDialog(parentFrame, msg);
}
}
}
I want to show an SWT dialog from AWT thread, i.e.
// call from AWT thread
void showSWTMessageDialog(String msg) {
???
}
I'm not sure, if I understand this question well, but when you are writing program with Albireo/SWT_AWT bridge, you use SWT normally and when you need, you can use Swing for some work (as this example on eclipse wiki shows).. So if you have your parent (most probably Shell
instance) in some global attribute, you can just create SWT dialog whenever and wherever you need..
EDIT
For blocking the AWT thread, you could call invokeAndWait() method of SwingUtilities
and inside the Runnable
instance show the SWT dialog window..
精彩评论