You should use setDividerLocation(double proportionalLocation)
to determine the initial space distribution of the JSplitPane
, and then call setResizeWeight(double)
with the same value to ensure that the panes are resized in proportion.
Also, be aware: Calling setDividerLocation(double)
before the JSplitPane
is visible will not work correctly, as the space calculation is based on the Component
's current size. Instead you need to involve a nasty hack, such as overriding the JPanel
's paint method that contains the JSplitPane
:
private boolean painted;
@Override
public void paint(Graphics g) {
super.paint(g);
if (!painted) {
painted = true;
splitPane.setDividerLocation(0.25);
}
}