Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting "SWTException: Invalid thread access"  RSS feed

 
Madi Meka
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hello Ranchers,

I get the following error on trying to access a different class on click of button

Exception in thread "main" org.eclipse.swt.SWTException: Invalid thread access

My code goes like this:

Calling class where main display is coded:



Trying to access following code



I learnt that following code must be used to solve the problem. But this didnt help me.




Please help.
 
Suraj Chandran
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exception in thread "main"org.eclipse.swt.SWTException: Invalid thread access


One thing is sure form above line that your display wasn't created in the main thread.
The display was created from some other thread.

A full trace can ahelp a little more
 
Madi Meka
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Main class



class being accessed:

 
Madi Meka
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello anybody der???
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We're still waiting for that full stack trace that tells where the error actually occurred; then you'll have to point out the line in the source that corresponds to the lines mentioned in the stack trace.
 
Madi Meka
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry i understood it wrong.... Here is the stack trace....



Exception in thread "main" org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:3563)
at org.eclipse.swt.SWT.error(SWT.java:3481)
at org.eclipse.swt.SWT.error(SWT.java:3452)
at org.eclipse.swt.widgets.Display.checkDisplay(Display.java:674)
at org.eclipse.swt.widgets.Display.create(Display.java:735)
at org.eclipse.swt.graphics.Device.<init>(Device.java:129)
at org.eclipse.swt.widgets.Display.<init>(Display.java:430)
at org.eclipse.swt.widgets.Display.<init>(Display.java:421)
at com.prodomestic.main.ProDomesticMain.<init>(ProDomesticMain.java:33)
at com.prodomestic.main.TenantDets.<init>(TenantDets.java:8)
at com.prodomestic.main.ProDomesticMain$1.widgetSelected(ProDomesticMain.java:208)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
at com.prodomestic.main.ProDomesticMain.mainscreen(ProDomesticMain.java:62)
at com.prodomestic.main.ProDomesticMain.main(ProDomesticMain.java:251)

Thank you.
 
Suraj Chandran
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check this thread. The same problem is explained:
http://dev.eclipse.org/mhonarc/lists/platform-swt-dev/msg05036.html

In the above case, the user was creating multiple displays within the same thread.
I can see from your trace that it is similar problem.

.
at org.eclipse.swt.widgets.Display.<init>(Display.java:421)
.
.
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)

From the above trace you can see that while one display is dispatching you are trying to create one more display, in the old displays thread.
You dont need two displays for sure.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!