How to add /arrange multiple items in a JPanel?

Hi,

I want to add several JLabels, JButton etc in my Container by using JPanels.

I have two JPanels one north and one center but i don't know how to arrange to JLabels, JButtons so it looks nice in the gui

public SpelerInvoeren(){

System.out.println("start SpelerInvoeren");

Container c = getContentPane();

c.setLayout(new GridLayout(3,1));

JPanel p =new JPanel();

JPanel pCenter =new JPanel();

northLbl =new JLabel("voer Speler 1");

player =new JLabel("Naam Speler");

beginSaldo =new JLabel("Begin bedrag:");

player1TF =new JTextField(45);

beginSaldo1TF =new JTextField(45);

startGame =new JButton("Start spel");

nextPlayer =new JButton("Volgende speler");

birth =new JLabel("Geboorte datum: ");

birth2TF =new JTextField(10);

quitGame =new JButton("Stoppen");

//NORTH JPanel

p.add(northLbl);

//CENTERJPanel

pCenter.add(player);

pCenter.add(player1TF);

pCenter.add(nextPlayer);

pCenter.add(player1TF);

pCenter.add(nextPlayer);

pCenter.add(beginSaldo);

pCenter.add(beginSaldo1TF);

pCenter.add(startGame);

pCenter.add(birth);

pCenter.add(birth2TF);

pCenter.add(quitGame);

c.add(p, BorderLayout.NORTH);

c.add(pCenter);

setTitle("SpelerInvoeren");

setSize(800,600);

setResizable(false);

setVisible(true);

}

I tried pack() and changing the size of the frame but I think there are easier/better ways to do this.

[2441 byte] By [deAppela] at [2007-11-27 4:48:17]
# 1
Use GridBagLayout and GridBagConstraints for components placement.
AnanSmritia at 2007-7-12 10:01:09 > top of Java-index,Desktop,Core GUI APIs...
# 2
[url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]How to Use Layout Managers[/url].You can nest different layout managers to get the layout you want.
camickra at 2007-7-12 10:01:09 > top of Java-index,Desktop,Core GUI APIs...
# 3
Thanks for the replies. The last one with the examples helped me a lot. ThanksArk
deAppela at 2007-7-12 10:01:09 > top of Java-index,Desktop,Core GUI APIs...