i want to know what actually is meaning between light weight and heavy weight components, but not in BIG TECHNICAL JARGAINS!!. also please anybody tell me what is the difference between a TRANSPARENT and OPAQUE object or component in swings!! thanks in advance
Heavyweight components are generally AWT components like Canvas, ScrollPane, Panel, etc. The reason they are called heavyweight is because they are ALWAYS painted on top. Swing components are considered Lightweight because unless specified otherwise, they are ALWAYS painted on the bottom. The difference between transparent and opaque is you can see through transparent. Opaque is Solid. Now, with that being said, I personally haven't ran across a situation where that mattered. If you go to java.sun.com and go through some of the tutorials, specifically the SWING tutorial, most of this stuff is in there. The very first paragraph of the SWING tutorial tells you what a heavyweight component is. I'm just telling you this because I have asked similar questions when I was first starting and people would just reply with "Look at the API". But what I learned was, it DOES help to look at the API and the tutorials BEFORE asking questions. Then, if you still don't understand, ask away. Good Luck!!
Put another way people are more inclined to help someone who has tried to help themselves than one who just is looking for the easy way out. This is not implying that the original question was looking for the easy way out.
Hi Nikhil, Gregg is correct in his discussion about Transparent and Opaque. The correct reason that Swing components are called light weight and AWT components are called heavy weight is because Swing is not implemented using native code( operating system), which is considered bulky or heavy. Therefore, it is considered light weight! All AWT components were implemented by the operating system in which the JVM was running. Since that was the case, a single application would look different running on different systems. Most Swing components are drawn themselves (in java API). This allows the components much more flexibility in actions and look and feel. Some Swing components are still considered heavy weight: JWindow JFrame JApplet These are still dragging around native methods. That is the reason why a JFrame in Windows will look like a Windows window and a JFrame on Unix will look like a Motif window. Regards, Manfred.
posted 17 years ago
Thanks a lot Manfred Leonhardt for giving me such a nice and easy reply. I have gone thro various articles on this on Sun Java site, but u have given the most brief and easy to understand solution. Thanks a lot!!