Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Embedding SWT Browser in Equinox launched Swing App on MacOS
Embedding SWT Browser in Equinox launched Swing App on MacOS [message #965772] Wed, 31 October 2012 13:42 Go to next message
Dan Pollitt is currently offline Dan PollittFriend
Messages: 55
Registered: August 2010
Hi all,

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()

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
Exception in thread "BrowserPanel SWT Thread"
org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(
at org.eclipse.swt.SWT.error(
at org.eclipse.swt.SWT.error(
at org.eclipse.swt.widgets.Display.error(
at org.eclipse.swt.widgets.Display.createDisplay(
at org.eclipse.swt.widgets.Display.create(
at org.eclipse.swt.widgets.Display.<init>(
at org.eclipse.swt.widgets.Display.<init>(

Versions of relevant things:

org.eclipse.swt_3.6.3.v3659f and

OS X Version 10.8.2

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,
Re: Embedding SWT Browser in Equinox launched Swing App on MacOS [message #968272 is a reply to message #965772] Fri, 02 November 2012 10:29 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 757
Registered: January 2012
Senior Member

I believe that on MacOS X, SWT *must* be the main thread. I think it will work providing you run with -XstartOnFirstThread and ensure your app first creates an SWT Diplay before doing any Swing/AWT operations (e.g., in IApplication#start()).

Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Previous Topic:How to disable text in a multi-line text box
Next Topic:Windows Meta File (WMF) support
Goto Forum:

Current Time: Sun Jun 24 09:30:57 GMT 2018

Powered by FUDForum. Page generated in 0.01496 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top