|
Description
|
The new AWT headless toolkit in JDK 1.4 allows developers to create instances of
lightweight components. (ie components with a lightweight peer)
Normally to realise (request peer creation) and layout these components
they are added to a top-level container such as a Window or Frame or (in the
case of Swing components, the JFrame subclass of Frame). However each of
these top-level components cannot be created in a headless toolkit.
In a headful toolkit a developer who wishes to create but not display these
componnets could create a Frame and call Frame.pack(). Clearly this is not
an option in the headles toolkit. The remaining options for developers in
a headless toolkit are to craft code which replicates the effect of pack(),
or to call Container.addNotify(). The former option may be fragile and
difficult without knowledge of the inner workings of the toolkit, the latter
is not strictly meant to be called by developers.
Since the headless toolkit was designed to allow creation of lightweight
Component hierarchies, it is important to show how this can be done in
a reliable, supported, cross platform way.
This is needed (for example) to be able to print Components in a headless
environment.
|