Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Swing heavy-weight components

 
Ranch Hand
Posts: 898
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?



 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
    Bookmark Topic Watch Topic
  • New Topic