adding components to a JFrame

Why does the following code only display 1 button. Surely there should be 2 buttons.

JFrame myFrame = new JFrame();

myFrame.setSize(1000,1000);

myFrame.setLayout( new GridLayout() );

JButton button1 = new JButton("Fred");

myFrame.add(button1);

myFrame.add(button1);

myFrame.setVisible( true );

[342 byte] By [sleepin_liona] at [2007-10-3 2:47:57]
# 1
> Surely there should be 2 buttons.button1 cannot be in 2 places at the same time
Michael_Dunna at 2007-7-14 20:36:44 > top of Java-index,Java Essentials,New To Java...
# 2
why cant a frame contain 2 buttons the same ?
sleepin_liona at 2007-7-14 20:36:44 > top of Java-index,Java Essentials,New To Java...
# 3
perhaps the simplest answer is the component (button1) only has one set of propertiesit only has 1 width, 1 height, 1 x-coord, 1 y-coord etcand components are displayed/laid out, according to their properties
Michael_Dunna at 2007-7-14 20:36:44 > top of Java-index,Java Essentials,New To Java...
# 4
thanx
sleepin_liona at 2007-7-14 20:36:44 > top of Java-index,Java Essentials,New To Java...