views:

484

answers:

1

I'm trying to create an application where there is a JSplitPane which contains the document tree on the left side and the current editor pane on the right. The editor pane has a toolbar as part of the edit pane. My problem is that when the JFrame containing the JSplitPane is resized as soon as the right component of the split pane reaches the size of the toolbar the right pane starts to 'squish' the left pane.

I was wondering if anyone knew of a way to keep the two components of the splitpane at the same ratio and have either the toolbar to stop displaying the items within it or have a 'more' button. I've got the tigris toolbar for the 'more' capability working in the frames toolbar, it just seems that it wont resize within the JScrollpane.

Thanks for the help.

+2  A: 

if i understand correctly, you are looking to get the split pane to treat both sides with the same priority when the parent frame is getting resized. if that is the case, you may want to look at the method JSplitPane.setResizeWeight(double).

Specifies how to distribute extra space when the size of the split pane changes. A value of 0, the default, indicates the right/bottom component gets all the extra space (the left/top component acts fixed), where as a value of 1 specifies the left/top component gets all the extra space (the right/bottom component acts fixed). Specifically, the left/top component gets (weight * diff) extra space and the right/bottom component gets (1 - weight) * diff extra space.

with that in mind, i would give 0.5 a try.

edit

looking at the code for the BasicSplitPaneUI, it will take the minimum size of both the left and right component into consideration when it is resizing, regardless of the the weight. the weight is still important, mind you. it is just trumped by the minimum of the components. with this in mind, try setting the minimun size on your toolbar or the scrollpane within which it is contained.

akf
hmm gave it a try and nothing changed. I think the issue is that the toolbar is needing to stay at its max size and going over the resizeweight of the JSplitPane and forcing the right component to have its width. thanks for the fast reply though.
schubySteve
would have upvoted too but i dont have the rep. Turns out i just needed to set the minimum size on the toolbar. left the resize weight as default and its all working. Thanks.
schubySteve