Class SWT_AWT_Bridge

java.lang.Object
org.jzy3d.bridge.swt.SWT_AWT_Bridge

public class SWT_AWT_Bridge extends Object
Adapts an AWT component into an SWT container. The following piece of code shows a convenient way of porting an AWT component to SWT:

    public class SWTplot extends AWTplot{
      public SWTplot(Composite parent){
        super();
        Bridge.adapt(parent, this);
      }
    }

Important notice: AWT components may trigger events (mouse, keyboard, component events, etc). When attaching a listener on a bridged AWT component that is supposed to modify an SWT widget (such as a text field), it is required to perform this modification into the SWT UI event queue. If not, the target SWT component will throw a SWTException with message "Invalid thread access". Indeed, all SWT widgets check that they are modified inside the UI thread.

Thus, it is suggested to compute events this way:
Text info = new Text(parent, SWT.None);
SWTplot plot = new SWTplot(parent);
plot.addPlotListener(new PlotListener(){
    public void handleEvent(Event e){
      Display.getDefault().asyncExec(new Runnable(){
        info.setText(e.toString());
      });
    }
});


If problems are encountered with the Bridge, it is possible to check:
https://wiki.eclipse.org/Albireo_SWT_AWT_bugs
http://www.eclipsezone.com/eclipse/forums/t45697.html
Author:
Martin Pernollet
  • Constructor Details

    • SWT_AWT_Bridge

      public SWT_AWT_Bridge()
  • Method Details

    • adapt

      public static void adapt(org.eclipse.swt.widgets.Composite containerSWT, Component componentAWT)
    • adaptIn

      public static void adaptIn(org.eclipse.swt.widgets.Composite embedder, Component componentAWT)