Java – align swing components across panels
We have a JPanel that contains multiple jpanels containing jcomponents (let's say jlabels and jlabels) JText@R_540_2419 @es)
Inside each JPanel, we use jgoodies layout to ensure the correct alignment of all labels
However, we certainly want all labels to align independently on the sub panel to which they belong
How can we do this without fixing the width of columns containing jlabels?
We can't give up jpanels because we have to have borders around component groups
Solution
Just because jpanels have borders doesn't mean they actually need to contain their obvious content Set the panel to transparent Add panels and components to the closed panel Add a spacing component to simulate the illustration of a panel in a layout For overlapping components, you also need to turn off optimize drawing or other similar