This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Swing heavy-weight components Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing heavy-weight components" Watch "Swing heavy-weight components" New topic
Author

Swing heavy-weight components

Guennadiy VANIN
Ranch Hand

Joined: Aug 30, 2001
Posts: 898
I could not quite understand:

  • what is the catch if Swing components do not have directly heavy-weight peers but only through its ancestors.


  • If JPanel instance is added as a component to JDialog container then JPanel instance is light-weight and JDialog component is heavy-weight? Corrrect?
    If I am trying to instantiate JPanel component outside of JDialog, then it is already light-weight. Correct?



Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

what is the catch if Swing components do not have directly heavy-weight peers but only through its ancestors.


If you have a Frame with a TextArea, a ComboBox and a Button on it, you will have 4 native peers taking up memory under AWT. If you have a JFrame with a JTextArea, a JComboBox, and a JButton on it, you will have only 1 native peer ( the JFrame ).


If JPanel instance is added as a component to JDialog container then JPanel instance is light-weight and JDialog component is heavy-weight? Corrrect? If I am trying to instantiate JPanel component outside of JDialog, then it is already light-weight. Correct?


You are correct about JPanel being a lightweight component and JDialog being a heavyweight component. But I do not understand how you are going to instantiate JPanel outside of JDialog ( or another top level heavyweight JFrame, JWindow, etc. ). All lightweight components have to have a heavyweight top level component to be drawn on... so you can't just have a JPanel floating around all by itself... it has to be drawn on a JFrame, JDialog, JApplet, or some other top level component.

-Nate

-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Swing heavy-weight components
 
Similar Threads
Swing an AWT
Swing - Content Pane vs. Panel - have I got this right?
Interview questions
Is JFrame added to JFrame heavyweight or lightweight?
how to make Canvas transparent ?