This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why JFrame is heavy?

 
Vinod Venugopal
Ranch Hand
Posts: 148
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic