A problem in displaying panel

the program below doesn't display the button until i maximize the frame

i just don't know what to do!!!

//

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;

public class MyFrame extends JFrame

{

public MyFrame()

{

super("Test");

setSize(600,400);

setLocation(100,100);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setVisible(true);

JPanel p = new JPanel();

getContentPane().add(p);

JButton b = new JButton("Hello Java");

p.add(b);

}

}

public class MainTest

{

public static void main(String[] args)

{

MyFrame f = new MyFrame();

}

}

[738 byte] By [bakr_awada] at [2007-10-2 8:00:09]
# 1
move setVisible(true) to after the lines where you add the components
Michael_Dunna at 2007-7-16 21:51:50 > top of Java-index,Desktop,Core GUI APIs...
# 2
Thanx Michael_Dunn;
bakr_awada at 2007-7-16 21:51:50 > top of Java-index,Desktop,Core GUI APIs...