org.jzy3d.bridge.swt
Class Bridge
java.lang.Object
org.jzy3d.bridge.swt.Bridge
public class Bridge
- extends java.lang.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:
http://wiki.eclipse.org/Albireo_SWT_AWT_bugs
http://www.eclipsezone.com/eclipse/forums/t45697.html
- Author:
- Martin Pernollet
Method Summary |
static void |
adapt(org.eclipse.swt.widgets.Composite containerSWT,
java.awt.Component componentAWT)
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Bridge
public Bridge()
adapt
public static void adapt(org.eclipse.swt.widgets.Composite containerSWT,
java.awt.Component componentAWT)