AWT verses Swings
1 posts in topic
Flat View  Flat View

Posted By:   Shilpa_Itgampalli
Posted On:   Friday, February 15, 2002 11:25 PM

I want TO Know why we prefer to use Swings componets in projects(i e proxy server) other then awt Components

Re: AWT verses Swings

Posted By:   Preyas_Joshi  
Posted On:   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.


Preyas Joshi
About | Sitemap | Contact