Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » No Display.getCurrent() when opening Swing Component
No Display.getCurrent() when opening Swing Component [message #160645] Mon, 06 December 2004 19:57 Go to next message
Florian Georg is currently offline Florian GeorgFriend
Messages: 22
Registered: July 2009
Junior Member
(already posted to eclipse.platform.swt - they sent me to this group)

Hello,

I have a (SWT based) GEF/draw2d application which opens a JFrame on
button click (pure Swing, not SWT_AWT !)
Beside from strange effects like deadlocks when using the Clipboard if
the JFrame is opened modal, I've got one somehow fundamental error:

The JFrame is opened, causing some visuals "from behind" to be marked as
invalid. The asynchronous (GEF-) repaint manager triggers something like
a repaint event with "Display.getCurrent().asyncExec(....)", which
results in a NullPointerException...
Is there no current display, if some Swing component has the focus ?
It sound plausible, as the current thread is no SWT ui-thread anymore...
but how can I work around this issue?
Changing the call into "Display.getDefault()" is no solution, as the
code is part of the GEF.

Any ideas ?

Thanks in advance
Florian
Re: No Display.getCurrent() when opening Swing Component [message #160707 is a reply to message #160645] Mon, 06 December 2004 23:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Can you post the stack trace?
Thanks.

"Florian Georg" <FGeorg@gmx.de> wrote in message
news:cp2dju$ras$1@www.eclipse.org...
> (already posted to eclipse.platform.swt - they sent me to this group)
>
> Hello,
>
> I have a (SWT based) GEF/draw2d application which opens a JFrame on
> button click (pure Swing, not SWT_AWT !)
> Beside from strange effects like deadlocks when using the Clipboard if
> the JFrame is opened modal, I've got one somehow fundamental error:
>
> The JFrame is opened, causing some visuals "from behind" to be marked as
> invalid. The asynchronous (GEF-) repaint manager triggers something like
> a repaint event with "Display.getCurrent().asyncExec(....)", which
> results in a NullPointerException...
> Is there no current display, if some Swing component has the focus ?
> It sound plausible, as the current thread is no SWT ui-thread anymore...
> but how can I work around this issue?
> Changing the call into "Display.getDefault()" is no solution, as the
> code is part of the GEF.
>
> Any ideas ?
>
> Thanks in advance
> Florian
Re: No Display.getCurrent() when opening Swing Component [message #160734 is a reply to message #160707] Tue, 07 December 2004 11:26 Go to previous messageGo to next message
Florian Georg is currently offline Florian GeorgFriend
Messages: 22
Registered: July 2009
Junior Member
Here's the stacktrace.

java.lang.NullPointerException
at
org.eclipse.draw2d.DeferredUpdateManager.queueWork(DeferredU pdateManager.java:146)
at
org.eclipse.draw2d.DeferredUpdateManager.addDirtyRegion(Defe rredUpdateManager.java:84)
at org.eclipse.draw2d.Figure.repaint(Figure.java:1184)
at org.eclipse.draw2d.Figure.repaint(Figure.java:1176)
at org.eclipse.draw2d.Figure.repaint(Figure.java:1191)
at org.eclipse.draw2d.Figure.setBackgroundColor(Figure.java:122 2)
at
de.unikn.hades.modeller.editor.figures.FlowNodeControlBarFig ure.setStatus(FlowNodeControlBarFigure.java:178)
at
de.unikn.hades.modeller.editor.parts.FlowNodeEditPart.update ControlBar(FlowNodeEditPart.java:241)
at
de.unikn.hades.modeller.editor.parts.FlowNodeEditPart.stateC hanged(FlowNodeEditPart.java:257)
at de.unikn.hades.node.Node.notifyStateListeners(Node.java:651)
at de.unikn.hades.node.Node.setDataTableSpec(Node.java:441)
at de.unikn.hades.node.NodeInPort.setDataTableSpec(NodeInPort.j ava:205)
at de.unikn.hades.node.NodeOutPort.sendDataTableSpec(NodeOutPor t.java:153)
at de.unikn.hades.node.Node.modelOutDataTableSpecChanged(Node.j ava:484)
at
de.unikn.hades.node.NodeModel.fireDataTableSpecChangedEvent( NodeModel.java:653)
at
de.unikn.hades.node.NodeModel.updateOutDataTableSpecs(NodeMo del.java:569)
at de.unikn.hades.node.NodeDialog.onOK(NodeDialog.java:179)
at de.unikn.hades.node.NodeDialog.access$0(NodeDialog.java:174)
at de.unikn.hades.node.NodeDialog$2.actionPerformed(NodeDialog. java:140)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at
javax.swing.AbstractButton$ForwardActionEvents.actionPerform ed(Unknown
Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unk nown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknow n Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Thanks !


Randy Hudson wrote:
> Can you post the stack trace?
> Thanks.
>
> "Florian Georg" <FGeorg@gmx.de> wrote in message
> news:cp2dju$ras$1@www.eclipse.org...
>
>>(already posted to eclipse.platform.swt - they sent me to this group)
>>
>>Hello,
>>
>>I have a (SWT based) GEF/draw2d application which opens a JFrame on
>>button click (pure Swing, not SWT_AWT !)
>>Beside from strange effects like deadlocks when using the Clipboard if
>>the JFrame is opened modal, I've got one somehow fundamental error:
>>
>>The JFrame is opened, causing some visuals "from behind" to be marked as
>>invalid. The asynchronous (GEF-) repaint manager triggers something like
>>a repaint event with "Display.getCurrent().asyncExec(....)", which
>>results in a NullPointerException...
>>Is there no current display, if some Swing component has the focus ?
>>It sound plausible, as the current thread is no SWT ui-thread anymore...
>>but how can I work around this issue?
>>Changing the call into "Display.getDefault()" is no solution, as the
>>code is part of the GEF.
>>
>>Any ideas ?
>>
>>Thanks in advance
>> Florian
>
>
>
Re: No Display.getCurrent() when opening Swing Component [message #160766 is a reply to message #160734] Tue, 07 December 2004 12:49 Go to previous message
Gunnar Wagenknecht is currently offline Gunnar WagenknechtFriend
Messages: 486
Registered: July 2009
Location: San Francisco ✈ Germany
Senior Member

Florian Georg schrieb:

> Here's the stacktrace.

>>> It sound plausible, as the current thread is no SWT ui-thread anymore...
>>> but how can I work around this issue?
>>> Changing the call into "Display.getDefault()" is no solution, as the
>>> code is part of the GEF.

Your are right, the current thread is the AWT event thread and not the
SWT thread. You just need to ensure that you are updating your figures
inside the SWT thread.

Use Display#syncExec/asyncExec(Runnable) when posintg events to the UI
(eg. when calling FlowNodeEditPart#updateControlBar).

Cu, Gunnar
Previous Topic:draw2D - editable text-boxes
Next Topic:could one EditPart have two ContentPane?
Goto Forum:
  


Current Time: Sun Oct 20 13:23:20 GMT 2024

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

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

Back to the top