I can't figure out why this won't put buttons 1, 2, and 3, on the top of the frame, with buttons 4, 5 and 6 on the bottom? I realize there should be space between the top row and the bottom row.
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
public class layoutExample
{
public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.setLayout(new BorderLayout(20, 40));
JButton jn1 = new JButton("Button 1");
JButton jn2 = new JButton("Button 2");
JButton jn3 = new JButton("Button 3");
JPanel panelCenter = new JPanel();
panelCenter.add(jn1);
panelCenter.add(jn2);
panelCenter.add(jn3);
frame.add(panelCenter, BorderLayout.CENTER);
JButton jn4 = new JButton("Button 4");
JButton jn5 = new JButton("Button 5");
JButton jn6 = new JButton("Button 6");
JPanel panelCenter2 = new JPanel();
panelCenter.add(jn4);
panelCenter.add(jn5);
panelCenter.add(jn6);
frame.add(panelCenter2, BorderLayout.SOUTH);
frame.setSize(570, 80);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}