Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Swing component to SWT?

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.

like image 630
Unni Kris Avatar asked Jan 03 '14 14:01

Unni Kris


1 Answers

You can use the SWT/AWT Bridge.

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

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.

like image 102
René Link Avatar answered Sep 30 '22 08:09

René Link