• 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

why JFrame is heavy?

 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could anyone tell me what could be the reason behind the universal Java truth that JFrame is not extended from JComponent ?
Vinod
 
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
Top level components (like Frame, JFrame, Window, JWindow, Dialog, JDialog, even JApplet) are a special case... they have to have a native peer (i.e. Each JFrame has a reference to a Windows (or Motif, or Mac, etc.) frame that it is drawn onto.), and they cannot be drawn inside other components (i.e. You can't put a JFrame inside another JFrame... JApplet's the special case of special cases here, because it can.) I would assume that Sun did this because they already had the code in place for a Frame, Applet, Window or Dialog to get a reference to a native peer and didn't want to have to duplicate that for JFrame, JApplet, JWindow, and JDialog.

However, to get around the problem of top level components not being JComponents, all the new Swing top level components have a root pane that does extend JComponent... which is the reason that you can't add JComponents directly to the JFrame, etc. and have to add it to the content pane (which is inside the layered pane, which is inside the root pane).

-Nate
reply
    Bookmark Topic Watch Topic
  • New Topic