如何将Swing组件添加到SWT? [英] How to add Swing component to SWT?

查看:166
本文介绍了如何将Swing组件添加到SWT?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在使用SWT的代码中添加一个Swing组件( JTree )。

有什么方法可以实现此目的?

我知道我们在SWT / Jface中具有 TreeViewer 组件,但是我已经开发了Jtree实现,并且想添加它

I want to add a Swing component (JTree) to my code which employs SWT.
Is there any way by which we can accomplish this?
I know that we have TreeViewer component in SWT/Jface, but i have got an already developed Jtree implemenatation and would like to add that, instead of rewriting using TreeViewer.

推荐答案

您可以使用SWT/AWT桥

Composite composite = new Composite(parent, SWT.EMBEDDED | SWT.NO_BACKGROUND);
Frame frame = SWT_AWT.new_Frame(composite);

SWT_AWT.newFrame(Compisite)方法将返回 java.awt.Frame 。由于框架容器,因此您可以添加任何 Component 。因此也是摆动组件。

The SWT_AWT.newFrame(Compisite) method will return a java.awt.Frame. Since a Frame is a Container you can add any Component. Thus also a swing component.

这篇关于如何将Swing组件添加到SWT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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