What are the components in the java technology are considered as lightweight and heavyweight, and what if we used lightweight components instead of heavyweight component..and what does the role they play in programming..
What are the components in the java technology are considered as lightweight and heavyweight, and what if we used lightweight components instead of heavyweight component..and what does the role they play in programming..
Lightweight components are the one which doesn’t go with the native call to obtain the graphical units. They share their parent component graphical units to render them. Example, Swing components, While in practice this sounds great, there are problems because not all native controls respond similarly to the same events. This can result in a Java program exhibiting different behavior under different Java AWT environments. What is a heavyweight component? - For every paint call, there will be a native call to get the graphical units. Example, AWT.
A lightweight component is one that subclasses java.awt.Component (or java.awt.Container) directly - implementing the look-and-feel of the component in Java rather than delegating the look-and-feel to a native peer. Lightweight components sometimes flash noticeably unless you put them in a container that performs double buffering. Lightweight components will not appear if their container implements a paint method that doesn't call super.paint. In other words, if you implement a container that performs some drawing.
One or more constructors. If the component responds to any events, such as mouse clicks, the constructor(s) should invoke the enableEvents method. Light weight Component is Swing, for ex: In swings If you want to create button the JVM is wont Ask that button to OS instead of it ill create its own button type. Light weight Component takes the components from the jvm, means it does not request the operating System for getting the components.
Bookmarks