Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between JFrame and JPanel

 
abrar alvi
Ranch Hand
Posts: 66
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to know the differences between JFrame and JPanel
 
Nam Ha Minh
Ranch Hand
Posts: 504
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
abrar alvi wrote:I would like to know the differences between JFrame and JPanel

JFrame is a window, whereas JPanel is just a lightweight container.
 
abrar alvi
Ranch Hand
Posts: 66
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nam Ha Minh wrote:
abrar alvi wrote:I would like to know the differences between JFrame and JPanel

JFrame is a window, whereas JPanel is just a lightweight container.


Can i get some example program to understand it better or some good article links.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure. You'll find those example programs in the tutorial. And you can find the tutorial by going to the API documentation for the two classes and following the links there.
 
Randall Twede
Ranch Hand
Posts: 4481
3
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
among other things JFrame does not inherit any swing stuff so it has no paintComponent() method like a JPanel.
IMO it is misnamed
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I disagree. It's no descendant of JComponent, but that's the only thing that would make it "not Swing", according to you. However, JComponent itself extends Container which extends Component, so both JFrame and JComponent have their roots in AWT. Also, JFrame uses several Swing components (JRootPane, JLayeredPane, JPanel for its content pane) for displaying the actual contents.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic