Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsEmbedding SWT Browser in Equinox launched Swing App on MacOS
https://www.eclipse.org/forums/index.php/mv/msg/422087/965772/#msg_965772
I have a large Swing application that runs ontop of Eclipse and is
started using the eclipse org.eclipse.core.runtime.applications
extension point.
In several places within the application we embed an SWT Browser
component within the Swing app using org.eclipse.swt.awt.SWT_AWT. We
maintain a single org.eclipse.swt.widgets.Display object that is created
in a new Thread (not the main(..) thread as we don't have access to
that), with that same thread being used to execute the readAndDispatch()
loop.
The app works as desired on Windows however we see the following when
Running on MacOS:
***WARNING: Display must be created on main thread due to Cocoa
restrictions.
Exception in thread "BrowserPanel SWT Thread"
org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:4083)
at org.eclipse.swt.SWT.error(SWT.java:3998)
at org.eclipse.swt.SWT.error(SWT.java:3969)
at org.eclipse.swt.widgets.Display.error(Display.java:1030)
at org.eclipse.swt.widgets.Display.createDisplay(Display.java:797)
at org.eclipse.swt.widgets.Display.create(Display.java:780)
at org.eclipse.swt.graphics.Device.<init>(Device.java:130)
at org.eclipse.swt.widgets.Display.<init>(Display.java:671)
at org.eclipse.swt.widgets.Display.<init>(Display.java:662)
Versions of relevant things:
SWT
org.eclipse.swt_3.6.3.v3659f and
org.eclipse.swt.cocoa.macosx.x86_64_3.6.3.v3659f
MacOS
OS X Version 10.8.2
Java
java.version=1.6.0_37
java.vendor=Apple Inc.
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
After doing some searching online I am confused as to how I should
address this (there seem to have been various SWT_AWT issues on MacOS
that have been resolved by different teams over the last 5 years or so).
I have seen reference to use of the -XstartOnFirstThread flag however
I'm not sure whether this is:
a) Still relevant
b) Appropriate, being that this is embedding SWT within Swing (as
opposed to the other way round) and that the app doesn't control the
main thread.
Can someone help me understand the state of the world regarding this
issue as of the MacOS/SWT/Java versions I'm using and ideally point me
in the right direction to resolve?
Many thanks,
Dan]]>Dan Pollitt2012-10-31T13:42:14-00:00Re: Embedding SWT Browser in Equinox launched Swing App on MacOS
https://www.eclipse.org/forums/index.php/mv/msg/422087/968272/#msg_968272
2012-11-02T10:29:25-00:00