Package org.jzy3d.bridge.swt
Class SWT_AWT_Bridge
java.lang.Object
org.jzy3d.bridge.swt.SWT_AWT_Bridge
Adapts an AWT component into an SWT container. The following piece of code shows a convenient way
of porting an AWT component to SWT:
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
Thus, it is suggested to compute events this way:
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
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 Summary
-
Method Summary
-
Constructor Details
-
SWT_AWT_Bridge
public SWT_AWT_Bridge()
-
-
Method Details
-
adapt
-
adaptIn
-