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?

Normally the Swing control would fill the entire view part under these conditions. I assume that the parent composite has a FillLayout set... you might want to check that to be sure. And by "parent", I mean the argument to createPartControl.

We have an example view that is fully filled with a JTable inside a JScrollPane. It's in org.eclipse.albireo.examples.plugin. See the org.eclipse.albireo.example.plugin.views.EmbeddedJTableView class. (link: http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.albireo/org.eclipse.albireo.examples.plugin/src/org/eclipse/albireo/examples/plugin/views/EmbeddedJTableView.java?root=Technology_Project&view=markup)

Does our example exhibit the same behavior for you? If so, then maybe there is something different about your environment. If not, then it would be worth looking into the differences between the example and your code.

Mark Millard wrote:
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

_______________________________________________
albireo-dev mailing list
albireo-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/albireo-dev




Back to the top