aspose file tools*
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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Adding JPanel to JFrame" Watch "Adding JPanel to JFrame" New topic
Author

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: 9993
    
    7

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.


[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 ,
Thanks!!!
very good help, I really appricaiate
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding JPanel to JFrame
 
Similar Threads
help! I cant get this to paint
Sub JPanel Size
How to Add Graphics to Jpanel
Problem with Adding JScrollPane to JPanel!
Null Pointer Exception in a GUI application