Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [albireo-dev] How to paint parent SWT widget?

I have a ViewPart that creates a SwingControl as a child of the Composite
that is passed in when createPartControl() is called. Something like:

public void createPartControl(Composite parent)
{
  SwingControl myControl = new SwingControl(parent, SWT.NONE)
  {
    Protected JComponent createSwingComponent()
    {
      JScrollPane pane = new JScrollPane();
      ...
      return pane;
    }
  };
}

The SwingControl updates fine and it appears that all the children of
JScrollPane render ok. The Swing widget hierarchy renders to a boundary that
is smaller than the ViewPart. I have the JScrollPane centered. The area
surrounding the SwingControl does not refresh, so there is cruft left over
from whatever was on top of that area before (such as another Window that
was moved over the top of it).

I tried adding a PaintListener to the parent SWT Composite, but I don't
receive any paint events. I don't see this problem under Windows but it is
quite bad under Linux.

***** Mark Millard *****

-----Original Message-----
From: Bruno Haible [mailto:haible@xxxxxxx] 
Sent: Wednesday, December 10, 2008 8:27 AM
To: albireo-dev@xxxxxxxxxxx
Cc: Mark Millard
Subject: Re: [albireo-dev] How to paint parent SWT widget?

Hello,

Mark Millard wrote:
> I have a SwingControl that center's itself relative to the parent SWT
> Composite widget. The parent widget doesn't seem to get the SWT paint or
> resize event. How do I repaint the parent widget

I'm not sure I understand the question right. It appears to be a question
purely about SWT widgets.
  - Paint events are sent by SWT to the affected SWT control only, not
    to its parents (assuming the parent is opaque). If you want that
    notification, you'll have to add a PaintListener to the control
    explicitly.
  - Notification about resized controls happens like this: The code that
    changes the size of a Control is also responsible for picking one
    of the ancestor of the control and invoking
      ancestor.layout(new Control[] { control });
    on it. The control is not supposed to propagate its size changes to
    its parent automatically.

If this does not answer your question, you may give a code sample to
highlight what you mean.

Bruno



Back to the top