Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » SWT_AWT Popup menu problem
SWT_AWT Popup menu problem [message #327969] Sat, 10 May 2008 18:19 Go to next message
Eclipse UserFriend
Originally posted by: asf14.yahoo.com

Hi

I've been stuck on this problem for a while. I am writing an graph
editor using jgraph as an eclipse editor plugin. I use SWT_AWT.newFrame
to attach the swing component onto eclipse. My problem now is how to
implement popup menus associated with mouse clicks.

When I simply create a SWT menu when a mouse right click occurs, I get a
org.eclipse.swt.SWTException: Invalid thread access.

I tried to pass the composite from the SWT_AWT.newFrame(composite) and run

composite.getShell().getDisplay().syncExec( new Runnable() {

public void run(){

Menu menu = new Menu(composite.getShell());
etc etc

}

}

I still get a thread error msg

Does anyone know how to approach this problem ?

Any help will be greatly appreciated,
David
Re: SWT_AWT Popup menu problem [message #327970 is a reply to message #327969] Sat, 10 May 2008 19:47 Go to previous messageGo to next message
Alessandro Mottadelli is currently offline Alessandro MottadelliFriend
Messages: 4
Registered: July 2009
Junior Member
I would suggest

Display.getDefault().syncExec() {}


Regards,
Sando
Re: SWT_AWT Popup menu problem [message #327971 is a reply to message #327969] Sat, 10 May 2008 20:32 Go to previous message
Gordon Hirsch is currently offline Gordon HirschFriend
Messages: 100
Registered: July 2009
Senior Member
composite.getShell() also cannot be called from a non-SWT thread, so as
Alessandro suggested, use Display.getDefault(). (Display.getCurrent() is
another option)

Also, it would be much better to call Display.asyncExec instead of
syncExec to avoid deadlock risk.

There are some issues in using popup menus in a mixed Swing/SWT
environment. You might want to look into the Albireo project
(http://www.eclipse.org/albireo - currently in alpha) which provides
specific support for SWT popups on a Swing control, among other things.

You also might be interested in the Swing/SWT integration article here:

http://www.eclipse.org/articles/article.php?file=Article-Swi ng-SWT-Integration/index.html

Dave wrote:
> Hi
>
> I've been stuck on this problem for a while. I am writing an graph
> editor using jgraph as an eclipse editor plugin. I use SWT_AWT.newFrame
> to attach the swing component onto eclipse. My problem now is how to
> implement popup menus associated with mouse clicks.
>
> When I simply create a SWT menu when a mouse right click occurs, I get a
> org.eclipse.swt.SWTException: Invalid thread access.
>
> I tried to pass the composite from the SWT_AWT.newFrame(composite) and run
>
> composite.getShell().getDisplay().syncExec( new Runnable() {
>
> public void run(){
>
> Menu menu = new Menu(composite.getShell());
> etc etc
>
> }
>
> }
>
> I still get a thread error msg
>
> Does anyone know how to approach this problem ?
>
> Any help will be greatly appreciated,
> David
Previous Topic:how to detect when the UI thread is running for a long time or even misused?
Next Topic:Exporting as aproduct
Goto Forum:
  


Current Time: Tue Jul 16 13:20:17 GMT 2024

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

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

Back to the top