<AWT Dev> <Swing Dev> Review request #3: 6852592 (revalidate() must be smarter)

Anthony Petrov Anthony.Petrov at Sun.COM
Thu Jul 23 11:03:28 PDT 2009

Hi Christopher,

On 7/23/2009 7:06 PM Christopher Deckers wrote:
>>    applet.getParent().validate();
> I remember a project where we had an Web 2.0 like page that contained
> many applets. We decided to rewrite the UI framework in Swing but the
> applets couldn't be migrated: applets were simple components for the
> web page and became simple components of our Swing application.
> Why would isValidateRoot not be coded like this for applets:
> return getParent() == null? true: false;
Applets always have a parent: it's either an embedded frame on the 
web-page, or your own container (such as a JFrame, or whatever). So this 
condition is not going to work as we would like it to.

> And as to how we would validate it, if the applet contains some Swing
> code, I guess users would not even notice what is happening behind the
> scene:
> someComponentInTheApplet.revalidate();
Calling the validate() method indicates that Artem is referring to an 
AWT application.

> Note that I don't particularily care about whether or not applets are
> validate roots, such applet integration is not very common.
Do the applets migrated from a web-page into your application resize 
themselves? If not, that means that they do not actually affect the 
layout of their containers, which, in turn, is the definition for 
validate roots. I bet in most cases the size of applets is specified by 
their embedder - a web-page, or an application. So I believe making the 
Applet class a validate root should not harm much. Though if in 0.001% 
of cases it does harm, one may easily override the method in their 
applet to return false, like: myContainer.add(new MyApplet() { public 
boolean isValidateRoot() { return false; } });

best regards,

More information about the awt-dev mailing list