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

Whats the point of extending JFrames and JPanels?

 
Bob Zoloman
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could someone please explain the purpose of extending a JFrame or JPanel? Also, how do you decide which one to extend? I can't seem to find much information on this subject, thanks.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my opinion, it's actually almost always not-so-good practice - I prefer to use composition over inheritance in those cases.
 
Dave Casman
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Extending JPanel is perfectly reasonable if your purpose is to also override paintComponent(). I think the usual method for providing custom painting/drawing in Swing is to extend JPanel.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dave Casman:
Extending JPanel is perfectly reasonable if your purpose is to also override paintComponent(). I think the usual method for providing custom painting/drawing in Swing is to extend JPanel.


Ah, yes, that might be true. It's just that I almost never have to do that...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic