We have a JPanel which contains multiple JPanels which contain JComponents (let’s say JLabels and JTextboxes)
Inside each of the internal JPanels we use JGoodies Layout in order to ensure proper alignment of all Labels.
But of course we would like to have all the Labels aligned independently on which subpanel they are.
How could we do that, without fixing the width of the column which contains the JLabels?
We can’t loose the JPanels since we have to have Borders around groups of Components.
Just because the
JPanels have borders, doesn’t mean that they actually need to contain their apparent contents. Set the panels to transparent. Add the panels and the components to the enclosing panel. Add spacer components to mimic the insets of the panels in the layout. You will also need to switch off “optimised drawing”, or some such, for overlapping components.