JSplitPane SetDividerLocation Problem

Goutham picture Goutham · Dec 10, 2009 · Viewed 17.4k times · Source

I have a JSplitPane which when shown should split the pane by 50%.

Now on giving an argument of 0.5 (as suggested) to setDividerLocation, Java seems to treat it as a normal number instead of a percentage. As in, the divider, instead of going to the middle of the pane, is almost at the start of the left pane (the pane is vertically split). Any work arounds?

Answer

Sam Dealey picture Sam Dealey · Aug 14, 2011

Am I missing something? There seem to be a lot of rather convoluted answers to this question... but I think a simple setResizeWeight(0.5) would solve the issue ... it's described in the SplitPane Tutorial