Any ideas on lightweight component support (probably important for swing)?
Tue Apr 22 03:27:00 GMT 2003
> scott > I therefore figured we needed to make LightweightPeer an
> scott > of ContainerPeer (rather than ComponentPeer) and return a
> scott > LightweightPeer from createComponent.
brian > I think this is wrong. A LightweightPeer is not necessarily a
brian > container, though you may implement a container based upon one.
In that case, where does java.awt.Container get its peer in the lightweight
There is no createContainer method in java.awt.Toolkit.
Should Container create its peer directly (without using Toolkit)?
> scott > createComponent javadoc from jdk 1.4.0:
> scott > -------------------------------------------
> scott > protected java.awt.peer.LightweightPeer createComponent(Component
> scott > Creates a peer for a component or container. This peer is
> scott > allows the Component and Container classes to be extended
directly to create
> scott > windowless components that are defined entirely in java.
brian > protected Component()
brian > Constructs a new component. Class Component can be extended directly
brian > to create a lightweight component that does not utilize an opaque
brian > native window. A lightweight component must be hosted by a native
brian > container somewhere higher up in the component tree (for example, by
brian > Frame object).
Right. Same deal for Container. But it doesn't work without the patch.
You get an exception when you try to create a lightweight Container.
brian > All JComponents extend Container.
Good point. The patch makes awt lightweight peers work the same way.
(i.e., so that GLightweightPeer implements ContainerPeer)
> scott > Does anyone see a flaw in this logic, or perhaps know of a
cleaner way to
> scott > get LightweightPeer working?
brian > I'm of the opinion Container is implemented on top of
brian > rather than inside of it.
As above, if that's what we do where does java.awt.Container obtain
a lightweight peer?
brian > --
brian > Brian Jones <firstname.lastname@example.org>
More information about the Java