Hi Thomas,

Am Donnerstag, den 23.02.2006, 20:51 -0500 schrieb Thomas Fitzsimmons:
> On Fri, 2006-02-24 at 00:10 +0100, Roman Kennke wrote:
> > > Hi Lillian,
> > > 
> > > > - reshape in Component was fixed. invalidate() was only being called on
> > > > the component if it has moved or has been resized. But the problem is
> > > > that a component could be moved, because its parent moved, and the
> > > > component would not know about it. 
> > > > invalidate() should always be called on the component when reshape (or
> > > > setBounds) is called. This way, all components are invalidated, in case
> > > > they have been moved or resized because of their parent.
> > > 
> > > I don't understand this one. When a component has reshape() called, then
> > > this has nothing to do with the parent beeing moved. If the parent
> > > moves, the relative position to the children will not change. However,
> > > the layout mechanism should update the relative child positions if
> > > necessary. I think we do not need to call invalidate() if the component
> > > has not moved or is not resized. However, if it is not removed or
> > > resized, we can simply return from this method call anyway.
> > 
> > I really think you should revert this, except if you can come up with a
> > testcase that shows that invalidate must be called when nothing really
> > changes. The only thing that I could imagine that matters is that
> > peer.setBounds could be called,
> 
> Yes, peer.setBounds does matter for heavyweight components in
> lightweight containers.  The peers have no way of knowing that a
> lightweight container has moved.  In our test case (MegaMek), a parent
> lightweight container moves but doesn't change size.  setBounds is
> called on its heavyweight children but the bounds that the children are
> given are relative to their parent so they think that they haven't moved
> when in fact they have.  If peer.setBounds isn't called then the peers
> won't update their positions relative to their lightweight parent.
> Lillian's gnu.testlet.java.awt.Container.LightweightContainer should
> demonstrate the problem but it doesn't at the moment (see my comments on
> mauve-patches).


Ok, I understand the problem. But AFAICS, reshape is only (guaranteed to
be) called when the component's relative (to its parent) position
actually changes. It might be (more or less accidentally) called by the
parent's layout manager, but that doesn't seem very reliable. The only
reliable way to detect moving or resizing parents is to register a
HierarchyBoundsListener on the interested component. I don't know if
that is an option for the heavyweight peers?

> The attached patch adds a clause to the early return condition which may
> be more acceptable.

That looks ok to me, but maybe you still want to consider the above
approach.

> A clearer approach may be to invalidate heavyweight descendants of
> lightweight containers in Container.invalidate.

No, invalidate() always only goes upwards in the component hierarchy.

> You can see by this added complexity why giving lightweight containers
> native representation is an attractive approach, for simplicity's sake.

Yeah, I begin to understand. :-/

/Roman

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

Reply via email to