my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes Difference between JFrame and JPanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Difference between JFrame and JPanel" Watch "Difference between JFrame and JPanel" New topic
Author

Difference between JFrame and JPanel

abrar alvi
Ranch Hand

Joined: Feb 01, 2012
Posts: 66

I would like to know the differences between JFrame and JPanel
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 498

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.


PM Me If You Want to get Urgent Help on Java Programming
abrar alvi
Ranch Hand

Joined: Feb 01, 2012
Posts: 66

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
Bartender

Joined: Oct 14, 2005
Posts: 18907
    
    8

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

Joined: Oct 21, 2000
Posts: 4347
    
    2

among other things JFrame does not inherit any swing stuff so it has no paintComponent() method like a JPanel.
IMO it is misnamed


SCJP
Visit my download page
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19761
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between JFrame and JPanel