Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » SWT Shell init Fails
SWT Shell init Fails [message #1748680] Sat, 26 November 2016 17:04 Go to next message
Ganesh K N is currently offline Ganesh K NFriend
Messages: 1
Registered: November 2016
Junior Member
Hi,

I have java project, which lanches two SWT dialogs, for some input. Sometime I got below exception while launch dialog. I googled it but found only display init issue. But i got shell init issue. Can some one help me on this.
public static Display getDisplay ()
{
Display display = Display.getCurrent ();
// may be null if outside the UI thread
if (display == null)
display = Display.getDefault ();
return display;
}
Display display = getDisplay();
Shell shell = new Shell(display);
....
.....
org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:4441)
at org.eclipse.swt.SWT.error(SWT.java:4356)
at org.eclipse.swt.SWT.error(SWT.java:4327)
at org.eclipse.swt.widgets.Widget.error(Widget.java:476)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:283)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:274)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:224)
at gui.lms.analysisRequestGUI.GenericDialog.showDialog(Unknown Source)
at gui.teamcenter.gui.actions.PublishAction$1.execute(Unknown Source)
at base_gui.basegui.util.WorkerThread.run(Unknown Source)
Re: SWT Shell init Fails [message #1748697 is a reply to message #1748680] Sun, 27 November 2016 10:20 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33226
Registered: July 2009
Senior Member
This isn't a JDT question. You can only create/access/update/use SWT widgets/controls on the UI thread, but here you are clearly doing it on another thread. You can use org.eclipse.swt.widgets.Display.asyncExec(Runnable) or org.eclipse.swt.widgets.Display.syncExec(Runnable) on any other thread to dispatch an event to the display thread.

Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:browser compatability
Next Topic:How do I auto-move dependencies of a statement as well, while moving the statement
Goto Forum:
  


Current Time: Sun Oct 13 16:06:04 GMT 2024

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

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

Back to the top