显示来自AWT/Swing的SWT模态对话框 [英] Showing SWT modal dialog from AWT/Swing

查看:151
本文介绍了显示来自AWT/Swing的SWT模态对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Albireo,很容易看到如何显示来自SWT的Swing对话框:

private AwtEnvironment awtEnv = 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);
        }
    }
}

我想显示一个来自AWT线程的SWT对话框,即

// call from AWT thread
void showSWTMessageDialog(String msg) {
    ???
}

解决方案

我不确定,如果我对这个问题理解得很好,但是当您使用Albireo/SWT_AWT桥编写程序时,可以正常使用SWT,并且在需要时,您可以使用Swing进行一些工作(如有关Eclipse Wiki的示例所示).您在某些全局属性中具有您的父级(最可能是Shell实例),您可以随时随地创建SWT对话框.

编辑

要阻止AWT线程,您可以调用 解决方案

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

这篇关于显示来自AWT/Swing的SWT模态对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆