Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding JPanel to JFrame

 
Behrouz Hosseini
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Behrouz,
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.
 
Behrouz Hosseini
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole ,
Thanks!!!
very good help, I really appricaiate
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic