I have not used MiGLayout after a while, and I donโt remember how to remove the space that is automatically set between the components. I tried to use the following parameters to no avail (note that I want to keep the horizontal distance):
novisualpadding
pad 0
insert 0
growy
Here is an example of what I mean: 
I would like the lines to be grouped in two. Thus, the first and second lines of JTextFields should not have a gap between them. However, I want to keep the gap between the second and third row. I want the third and fourth lines to be grouped without spaces between them, etc.
Here is the relevant part of my code for the layout (this is in a class that extends JPanel):
setLayout(new MigLayout("insets 0", "grow")); //Code to create the JTextFields not shown as it is not relevant for(int i = 0; i < textFields.length; ++i) { for(int j = 0; j < textFields[0].length; ++j) { textFields[i][j].setPreferredSize(new Dimension(80, 50)); if(j == 0 && i % 2 == 0) //If it the first JTextField in an even row add(textFields[i][j], "newline, split, gaptop 5, gapright 5"); else if(j == 0 && i % 2 != 0) //If it the first JTextField in an odd row add(textFields[i][j], "newline, split, gapright 5"); else //if it any other JTextField add(textFields[i][j], "gapright 5"); } }
Basically, I use loops to traverse all my components, then I set a space above the odd lines, because where I want a space between the lines in my components and for other components, I set the same parameters except for this space.
In the end, I'm going to group all the JTextFields from the same row in the JPanel and add JPanels to the layout instead, but that doesn't matter at the moment.
source share