Question

I am using a grouplayout to manage 3 jpanels. Below is a screenshot of what it looks like (I cannot get a full screenshot for confidentiality reasons). The green border is the mainPanel, which has grouplayout attached to it. The three black borders are three jpanels with different components. As you can see, grouplayout creates a padding (about 20px), automatically. This happens only to the right hand side border and left hand side border is ok. I've tried setAutoCreateContainerGaps(false) and setAutoCreateGaps(false) and nothing seems to work. Also, the maxsize of the mainPanel, as returned by groupLayout's maximumLayoutSize(mainPanel) is 642px,540px, but the longest jpanel of those three panels is only 630px (set explicitly). Why does it add those extra pixels? only to the right side? How do I get rid of this padding/space?

enter image description here

Was it helpful?

Solution

I think I got this. I tried setting mainPanel.setPreferredSize() and the grouplayout started honoring that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top