Saturday, February 16, 2002 02:06 AM
AWT is heavyweight. In AWT when you create a Window or Frame, it has a native peer so the creation of the component is handled by the native platform. This causes a few problems :
1. Native windows can be heavyweight, so it's undesirable to have too many of them.
2. Native windows are opaque, so they can't be used to implement transparent regions.
3. Native windows are handled differently across platforms, so the AWT has to struggle to maintain a consistent view across these varied platforms.
Lightweight Swing components have the ability to directly extend the java.awt.Component and java.awt.Container classes in order to create components which do not have native opaque windows associated with them.
1. As a result the Lightweight component can have transparent areas by simply not rendering to those areas in its paint() method.... as long as you keep the component rectangular, that is :)
2. The Lightweight component requires no native data-structures or peer classes.
3. There is no native code required to process lightweight components, hence handling of lightweights is 100% implemented in common java code, which leads to complete consistency across platforms.