In Swing, what\'s the best way to make the JSplitPane to split two jpanels with 50% size each.
It looks like if I don\'t set preferred sizes on the panels it always make
I had a similar problem and I solved it by using a component listener in the parent container and set the divider location on the first resize. Initialise a variable firstResize to true and add this into the parent container constructor:
addComponentListener(new ComponentAdapter(){
@Override
public void componentResized(ComponentEvent e) {
if(firstResize){
splitPane.setDividerLocation(0.5);
firstResize = false;
}
}
});
This should cause the divider to be centred when the parent container size is first set.