[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Embedded SWT_AWT EventQueue Exceptions

You are right. The the AWT frame has to be embedded directly into
a Composite with the SWT.EMBEDDED style.


Robert Brady <rpbrady@xxxxxxxxx>
Sent by: platform-swt-dev-bounces@xxxxxxxxxxx

10/14/2005 05:12 PM

Please respond to
"Eclipse Platform SWT component developers list."

[platform-swt-dev] Embedded SWT_AWT EventQueue Exceptions

Hi All,

I found that when embedding an AWT frame into an SWT Group that I get
EventQueue NullPointerExceptions.  However, if I simply wrap the SWT
Group inside a Composite, the error goes away.  I suspect that the
SWT_AWT Frame has to be a direct child of Composite and that using a
subclass of Composite doesn't work.  Has anyone experienced this
before?  Is this a bug?  Do you agree that every SWT_AWT Frame should
be inside a Composite and not one of Composite's subclasses?  Thanks
and details below


Here is the snippet used for the Group case:

   awtBridgeGroup = new Group (parentGroup, SWT.EMBEDDED);
   awtBridgeGroup.setLayout (new GridLayout ());
   awtBridgeGroup.setLayoutData (new GridData (GridData.FILL_BOTH));
   awtBridgeGroup.setText ("Awt Bridge");
   awtBridgeGroup.setSize (300, 300);

   awtTopFrame = SWT_AWT.new_Frame (awtBridgeGroup);

and for the Composite wrapper case:

  awtBridgeGroup = new Group (parentGroup, SWT.EMBEDDED);
   awtBridgeGroup.setLayout (new GridLayout ());
   awtBridgeGroup.setLayoutData (new GridData (GridData.FILL_BOTH));
   awtBridgeGroup.setText ("Awt Bridge");
   awtBridgeGroup.setSize (300, 300);

       Composite embeddedComposite = new Composite(awtBridgeGroup,  
                 embeddedComposite.setLayout(new GridLayout());
                 embeddedComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
                 embeddedComposite.setSize(awtBridgeGroup.getSize().x - 5,
awtBridgeGroup.getSize().y -5);

   awtTopFrame = SWT_AWT.new_Frame (embeddedComposite);

If I don't use a composite wrapper, then I get the exception below
when closing the window.  For some reason using a subclass of
Composite to contain the SWT_AWT Frame doesn't kill off the
WComponentPeer in the AWT EventQueue?

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException:
null pData
                at sun.awt.windows.WComponentPeer.hide(Native Method)
                at java.awt.Component.hide(Component.java:1336)
                at java.awt.Window.hide(Window.java:565)
                at sun.awt.EmbeddedFrame.hide(EmbeddedFrame.java:176)
                at java.awt.Window$1DisposeAction.run(Window.java:627)
                at java.awt.Window.doDispose(Window.java:641)
                at java.awt.Window.dispose(Window.java:596)
                at org.eclipse.swt.awt.SWT_AWT$2.run(SWT_AWT.java:164)
                at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
                at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
                at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
platform-swt-dev mailing list