This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Adding JPanel to JFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Adding JPanel to JFrame" Watch "Adding JPanel to JFrame" New topic

Adding JPanel to JFrame

Behrouz Hosseini
Ranch Hand

Joined: Feb 15, 2010
Posts: 31
Hi Every one,
I am new at java swing and I am trying to add a Jpanel to my frame. I have three simple class as below
1-Class MyPanel
2-Class MyFrame
3-Class Main
I did my best to add the panel to my frame but it did not work! Could you please let me know what I am doing wrong!?

Best Regards
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10768

Welcome to the Ranch.

In MyPanel, you are adding the button to some different panel! Try changing pan.add(okButton); to this.add(okButton)
Check out the Swing tutorial. It is usally a good place to start learning Swing.

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Behrouz Hosseini
Ranch Hand

Joined: Feb 15, 2010
Posts: 31
Maneesh Godbole ,
very good help, I really appricaiate
I agree. Here's the link:
subject: Adding JPanel to JFrame
jQuery in Action, 3rd edition