I need to align all the fields with the respective labels,
here is my
After some findings - MigLayout looks to be the best option for me
Code will be just the following:
JPanel parentPanel = new JPanel(new MigLayout("wrap 2")); //Autowrap after each 2 elements
parentPanel.add(label1);
parentPanel.add(field1);
parentPanel.add(label2);
parentPanel.add(field2);
...
No need to specify indexes by hand or create some huge layout infrastructure - simple code to get conceptually simple result. Please see the QuickStart guide: http://www.miglayout.com/QuickStart.pdf
You can plug it in or directly download from Maven: https://mvnrepository.com/artifact/com.miglayout/miglayout