aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes lightweight component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "lightweight component" Watch "lightweight component" New topic
Author

lightweight component

thanvi janu
Greenhorn

Joined: Nov 16, 2009
Posts: 29
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

Joined: Nov 03, 2009
Posts: 101
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


SCJP, SCWCD
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
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

bitguru blog
 
 
subject: lightweight component