JSplitPane and component minimum sizes

Hi,

I notice that when you have a JSplitPane, it restricts its divider adjustment to obey the minimum sizes of the components in the panels of its left and right sides.
However if I dynamically change whats in these panels the divider remains where it was, and if the panel is now too cluttered the min sizes are no longer being obeyed .... However! if you now click on the divider it automatically jumps to a position to "re-obey" the minimum sizes.

My question - can i get this to happen automatically when i add components to one of the panels or on a window is resize event??
cathalmchaleAsked:
Who is Participating?
 
zzynxConnect With a Mentor Software engineerCommented:
>>My question - can i get this to happen automatically when i add components to one of the panels or on a window is resize event??

JSplitPane.setDividerLocation
         public void setDividerLocation(double proportionalLocation)

Sets the divider location as a percentage of the JSplitPane's size.
This method is implemented in terms of setDividerLocation(int). This method immediately changes the size of the split pane based on its current size. If the split pane is not correctly realized and on screen, this method will have no effect (new divider location will become (current size * proportionalLocation) which is 0).

Parameters:
proportionalLocation - a double-precision floating point value that specifies a percentage, from zero (top/left) to 1.0 (bottom/right)


>>Also i would like a bit of space between the left panel -> the divider -> the right panel.  how do i do this??
Give your left and right panels an empty border. You can specify the top,left, bottom and right spaces

E.g.
leftPanel.setBorder( new EmptyBorder(0, 0, 0, 10) );  // add extra space only on the right of this left panel
rightPanel.setBorder( new EmptyBorder(0, 10, 0, 0) ); // add extra space only on the left of this right panel

0
 
objectsCommented:
try calling revalidate() on the split pane after changing the panel layout.
0
 
cathalmchaleAuthor Commented:
Also i would like a bit of space between the left panel -> the divider -> the right panel.  how do i do this??
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
armoghanCommented:
To make space use setDividerSize();
0
 
cathalmchaleAuthor Commented:
tried calling revalidate()  it didnt work. I will check back later, thanks
0
 
cathalmchaleAuthor Commented:
Hi again,

>>To make space use setDividerSize();
this doesnt really do what i want - i would like some space around the perimeters of the left and right panels.

also any further ideas on my original question
>>My question - can i get this to happen automatically when i add components to one of the panels or on a window is resize event??
0
 
cathalmchaleAuthor Commented:
???
0
 
zzynxSoftware engineerCommented:
Thanks for accepting

I saw this one was already open some time...
0
All Courses

From novice to tech pro — start learning today.