Adjusting size of JPanels in JSplitPane
You can adjust the position of the split pane divider by calling:
spane.setDividerLocation(0.5);
Or you can rearrange the way it splits the space between the two parts with:
spane.setResizeWeight(1.0); // equal weights to top and bottom
You might want to figure out how to remove the blank space from the profile panel and that would help, too.
But I think the real problem might be the size of the frame itself. You didn't show that part of the code.
You might try enlarging the starting size of the JFrame and see how the layouts rearrange things.
(On a side note: I usually fix up the buttons to be on the right side of their own little panel by using a flow layout with right justification.)
Another way is to set the JPanel
's dimensions with setPreferredSizes(new Dimension(width, height))
and invoke resetToPreferredSizes()
on the JSplitPane
.
From the JSplitPane's javadoc
To resize the Components to their preferred sizes invoke resetToPreferredSizes.
When the user is resizing the Components the minimum size of the Components is used to determine the maximum/minimum position the Components can be set to. If the minimum size of the two components is greater than the size of the split pane the divider will not allow you to resize it. To alter the minimum size of a JComponent, see JComponent.setMinimumSize(java.awt.Dimension).
When the user resizes the split pane the new space is distributed between the two components based on the resizeWeight property. A value of 0, the default, indicates the right/bottom component gets all the space, where as a value of 1 indicates the left/top component gets all the space.
Maybe you can use JSplitPane#setDividerLocation(aDouble)
too.