Win a copy of Java Challengers this week in the Java in General 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

So many window Panes in JFrame?

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These panes are pains for me. Just was reading in a book that a JFrame contains a number of panes namely : JRoot, JLayeredPane, ContentPane Glass pane. Why are there so many panes? Whare are their uses?
Again, why should we attatch a JPanel with the contentPane of a JFrame in order to draw something? Why can't we directly draw something directly on the JFrame?
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you could. But then you couldn't use the facilities that JFrame offers. For example, the glass pane can be used to block mouse input during long-running operations, or to draw some kind of overlay over the window. Using the content pane properly allows the root pane to manage a menu bar in the window.

But if you play by the rules -- most notably, by using a separate panel to paint in, rather than trying to paint right on the frame -- then you get these capabilities for free. You don't even need to think about them if you don't use them directly. Many basic Swing programmers are completely unaware that they exist.

If you haven't already, you might like to read this page about how the pieces of a JFrame fit together.

I'm moving this to our Swing/AWT forum for any further discussion.
 
Prosenjit Banerjee
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much. You helped me a lot. Specially the java tutorial referred by you gave me a great knowledge.
 
This will take every ounce of my mental strength! All for a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic