• Post Reply Bookmark Topic Watch Topic
  • New Topic

JPanel vs. JComponent

 
Scott Presley
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to create a custom 'widget', and I was going to extend JPanel. The more I read though, the more I'm curious, what's the difference between JComponent and JPanel? Is there any advantage to using JPanel or is it just convention?

Thanks,
cotfessi
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JPanel is often opaque, depending on LAF (GTK+ is advertized as non–opaque); JComponent is non–opaque.

JPanel has a default background color; JComponent does not.

JPanel comes with a default FlowLayout layout manager; JComponent has none.

Either one might work okay depending on what you need. JPanel seems to be a convenience for most gui work.

[ June 18, 2004: Message edited by: Craig Wood ]
 
Paper has not yet been outlawed – so let your Java Swing application print with wild abandon: JPDF
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!