• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Swing heavy-weight components

 
Ranch Hand
Posts: 898
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic