Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Heavy weight vs. Light weight component

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between a heavy weight Swing component and a light weight Swing component?
- Mike
 
Author
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A heavyweight component relies on native code for its visual representation so it is drawn by the underlying operating system. Heavyweight components are those defined in the java.awt package
A lightweight component does not rely on native code - it is implemented entirely in Java. This means that a lightweight componet is entirely portable.
One consequence of the difference between heavyweight and lightweight components is that mixing them in the same application can cause trouble because they are drawn in different ways. You should avoid mixing them.
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An excellent article about heavyweight and lightweight components:
Swing connection: Mixing heavy and light components
Java Tutorial's $.02


As a rule, programs should not use "heavyweight" AWT components alongside Swing components. Heavyweight components include all the ready-to-use AWT components, such as Menu and ScrollPane, and all components that inherit from the AWT Canvas and Panel classes. When Swing components (and all other "lightweight" components) overlap with heavyweight components, the heavyweight component is always painted on top.


[ March 28, 2002: Message edited by: Valentin Crettaz ]
 
Hey! Wanna see my flashlight? It looks like this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic