tags:

views:

197

answers:

2

Afternoon,

I'm working on an Eclipse RCP plugin. I want to embed a Swing component into it. At the moment I'm using a SWT <-> AWT bridge like this:

Applet applet = new myApplet();
Composite swtAwtComponent = new Composite(parent, SWT.EMBEDDED);
java.awt.Frame frame = SWT_AWT.new_Frame( swtAwtComponent );
applet.init();
frame.add(applet);

Are there any signficant issues with this approach, or equally is there a better approach I should consider? How will this affect threading / concurrency in the application.

Thanks

+1  A: 

There are definetly some issues with SWT_AWT bridge:

  1. The most important ofcourse is the threading issue. The problem here is that when you use both SWT and AWT, you are essentially using two GUI threads. Proper synchronization between them is absolutely necessary or you will often end up with deadlocks. In most cases you can avoid it by using EventQueue#invokeLater or Display#asyncExec.

  2. The second major problem is the Modality issues. SWT has its own modality stack and AWT has its own. You may need to work around these too. There are known solutions for this.

  3. You may see Look and feel inconsistencies here and there and may need to fix case-to-case basis.

  4. There are small other problems like sometimes mouse wheel scroll does not work on some platforms.

Please make sure you read and understand the FAQ before doing something big using SWT_AWT.

Suraj Chandran
Excellent answer, thank you very much for this :)
dangerstat
A: 

Hi Suraj,

I want to know how I could resolve the issues of SWT_AWT brdige. I want to know if there is any solution in code?

Regards,

AEHP

AEHP