<AWT Dev> <Swing Dev> Regarding the fix for 6852592 (revalidate() must be smarter)

Anthony Petrov Anthony.Petrov at Sun.COM
Fri Aug 14 05:13:46 PDT 2009


Alex Potochkin proposed another solution:

3. The Window.show() (as well as Window.pack()) must validate *all* 
invalid containers within their hierarchies. It should not silently skip 
already valid containers: the children of the container (and children of 
children, ans so on) should also be examined for validity and validated 
if needed.

After reading the current specification of the Container.add() methods 
it seems that they actually insist on subsequent validating of the 
hierarchy only if the container is displayable, If it isn't displayable 
yet, it looks like the specification does not require manual validation. 
That may suggest that the failing test case is quite 
specification-compliant, and therefore the solution #1 below isn't quite 
correct.

Comments? Other proposals? A decision?

--
best regards,
Anthony


On 08/12/2009 05:39 PM, Peter Zhelezniakov wrote:
> Anthony Petrov wrote:
>> Possible solutions include:
>>
>> 1. Adding a call to revalidate() method immediately after the 
>> components have been added to the container in the test code. However, 
>> from Swing perspective this looks like a backward incompatibility.
>>
>> 2. Overriding the JComponent.addImpl() method and putting the call to 
>> revalidate() there. This, however, may introduce some performance 
>> regression.
> 
> I like #2. Adding children to a container does indeed affect the 
> container's layout, so it's reasonable to call revalidate().
> 



More information about the awt-dev mailing list