<Swing Dev> <AWT Dev> Review request #3: 6852592 (revalidate() must be smarter)
Anthony Petrov
Anthony.Petrov at Sun.COM
Fri Jul 24 12:06:18 UTC 2009
Hi Chris,
On 07/24/2009 12:10 AM, Christopher Deckers wrote:
>> 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.
>
> If I understand correctly, the logical validate root in case of the
> browser is the browser frame, not really the applet. The applet is
> just a container that can be placed in a web browser and I don't see
> why it would have a different treatment than a Panel for example.
If all browsers were written in Java, we could possibly say so. Given
this is not the case, we just can't expose our concepts (like validate
roots, and validating in general) beyond the bounds of a Java components
hierarchy.
> I can understand we don't have a handle to the Window object
We actually do. If you examine an object returned by the
applet.getParent() when the applet is running on a web page, you can
notice that it is an instance of the sun.awt.EmbeddedFrame class which
extends java.awt.Frame. But anyway, this is an implementation detail,
and we don't really want to tell the users to get the parent of their
applets and then call validate() on this parent. For a typical user an
Applet is conceptually the root of their components hierarchy, therefore
they imply it's enough to validate just that applet to have the whole
hierarchy valid. However, w/o making the Applet a validate root we'll
end up with the embedded frame being invalid forever.
> containing the applet so we can't really call validate(), hence this
> work around.
>
> This is mostly a conceptual discussion, as I said I don't really care
> about the outcome for the Applet case :)
>
> Slightly off-topic feature: wouldn't it be conceptually possible to
> have a special parameter in the applet tag that specifies to use the
> preferred size rather than an hardcoded size? That way applet that
> declare not being validate roots would really be like any other HTML
> elements and would automatically resize following
> invalidation/validation cycles. This would also be useful if an applet
> has a size that cannot be hardcoded (depending on font sizes or
> whatever).
Theoretically I agree with the concept. However, this is a difficult
task that would require a lot of collaboration between the Plugin and
AWT teams, and what's more important (or sad?), might be incompatible
with some web-browsers. So this seems like a cool idea, but I hardly see
it implemented in the near future.
--
best regards,
Anthony
More information about the swing-dev
mailing list