Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

lightweight component

 
thanvi janu
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A lightweight component is one that "borrows" the screen resource of an ancestor (which means it has no native resource of its own -- so it's "lighter").

what is the native resource?

Can anyone give me examples of lightweight component and heavy weight component.
 
Rok Štelcer
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

thanvi janu wrote:Can anyone give me examples of lightweight component and heavy weight component.

heavyweight component --> AWT
lightweight component --> Swing

The main difference is that in Swing each component is painted(rendered), while in AWT "everything" is inherited from its native peer.


Regards,
Rok
 
Brian Cole
Author
Ranch Hand
Posts: 903
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rok Štelcer wrote:
heavyweight component --> AWT
lightweight component --> Swing

The main difference is that in Swing each component is painted(rendered), while in AWT "everything" is inherited from its native peer.


In particular, these AWT native peers allocate native resources. For example java.awt.TextField allocates an actual text-field-like resource* through the native OS while javax.swing.JTextField does not. JTextField simply draws pixels and interprets mouse events to emulate a native** text field.


footnotes:

*probably, depending on how AWT was ported to the native OS

**or other-than-native, depending on which LookAndFeel is in effect
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic