Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Tip on Mixing Heavyweight and Lightweight Java Components

By Laura Bennett
2003-10-01


The resolution

table cellspacing="0" cellpadding="5" width="30%" align="right" border="1">

An exception to the rule

The JComboBox class differs from other Swing classes in that it does offer a method called setLightWeightPopupEnabled(Boolean aFlag). This method allows you make the popup a heavyweight object so that it will appear on top of a Frame window. This is the exception rather than the rule.
Now that we know what the problem is, how do we handle it? JDK 1.1 implemented the Lightweight UI Framework. The Swing classes use the Lightweight UI Framework, giving you the ability to extend the AWT Component and Container classes that do not have native opaque windows. Classes that currently subclass the heavyweight objects can adapt to this model by changing the class they subclass from.

The bottom line is that you should not mix heavyweight and lightweight objects. Follow one path or the other so that your application has a unified and consistent view across platforms. The advantages of using all lightweight objects include supporting transparent areas, the lack of additional peer classes (thus improving performance), and the ability to say that you used 100% Java code.



Tutorial Pages:
» The Problem
» The answer
» The resolution
» Resources


First published by IBM DeveloperWorks


 | Bookmark
Related Tutorials:
» All about JAXP, Part 1
» Make Database Queries Without the Database
» Load List Values for Improved Efficiency
» 2 Ways To Implement Session Tracking
» A Simple Way to Read an XML File in Java
» Develop Aspect-Oriented Java Applications with Eclipse and AJDT

Advertise with Us!