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
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply 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: 364

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.


Job Offer: Online working Java technical writing
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: 16487
    
    2

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: 4095
    
    1
among other things JFrame does not inherit any swing stuff so it has no paintComponent() method like a JPanel.
IMO it is misnamed


SCJP
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19232

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
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Difference between JFrame and JPanel
 
Similar Threads
Difference between JPanel and JFrame
Difference between JFrame and JPanel
contentPane
swing
JPanel and JFrame