Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

meaning of lightweight?

 
Jothi Pandyan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what does lightweight (components) mean
what are its advantages
thanks in advance.
 
Peter Lyons
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd try to paraphrase what I've picked up in reading, but I'm not sure I get it either.
Check out this article. http://java.sun.com/products/jfc/tsc/articles/mixing/index.html
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lightweight components are those without peer windows in the host system. Heavyweight components, even simple things like buttons, each have a corresponding window in the underlying OS.
This has implications for the capabilities and behavior of components. For instance, when you click on a heavyweight component, the window in the OS gets the click event and sends it to the VM. When you click on a lightweight component, the click falls through to the first heavyweight component (usually a JFrame), which must then decide which lightweight was actually clicked, and call its event handler. Another difference is that lightweight components may have transparent areas. It's true that some OS's windowing systems allow transparency, but the native code behind the AWT doesn't use it, so your only alternative for non-rectangular buttons and the like is to use lightweight components.
Because they are implemented entirely in Java, lightweight components are far more flexible. You can control their appearance and event handling to a far greater degree than heavyweights, which depend on the native code that supports the AWT.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic