How to align the items in a form (grid layout)?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • onlybarca

    How to align the items in a form (grid layout)?

    I need to place JLabels and JTextFields in a panel and align them as a form:

    Name: <text field>
    Surname: <text field>
    Address: <textfield>

    etc.

    I'm trying to use GridLayout.


    panel1.setLayou t(new GridLayout(1,2) );


    It works, but the spaces between labels and text fields are very big. How to make them smaller?
    Or maybe I should us a different layout for that?

    Please help
Working...