Thought I'd post some code how to do it with GridBagLayout as well. Could be useful for when you have something that does not fit so perfectly with BorderLayout, which will be often when making GUIs.
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
JFrame frame = new JFrame("GridBagLayout Demo");
frame.setLayout(new GridBagLayout());
JLabel label = new JLabel("Demo Label");
JTextField textField = new JTextField("Demo Text");
JComboBox comboBox = new JComboBox(new String[] {"hello", "goodbye", "foo"});
GridBagConstraints cons = new GridBagConstraints();
cons.insets = new Insets(10, 10, 10, 10);
frame.add(label, cons);
cons.gridx = 1;
cons.weightx = 1;
cons.weighty = 1;
cons.insets = new Insets(10, 0, 10, 10);
cons.fill = GridBagConstraints.HORIZONTAL;
frame.add(textField, cons);
cons.gridx = 2;
cons.weightx = 0;
cons.weighty = 0;
cons.insets = new Insets(10, 0, 10, 10);
cons.fill = GridBagConstraints.NONE;
frame.add(comboBox, cons);
frame.pack();
frame.setVisible(true);
}
}