Did you read the documentation? How to Use GridBagLayout (The Java™ Tutorials > Creating a GUI With JFC/Swing > Laying Out Components Within a Container)

Anyway, here you have a small code which...