Solved

JSplitPane and component minimum sizes

Posted on 2004-09-02
8
713 Views
Last Modified: 2008-03-10
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??
0
Comment
Question by:cathalmchale
8 Comments
 
LVL 92

Expert Comment

by:objects
Comment Utility
try calling revalidate() on the split pane after changing the panel layout.
0
 

Author Comment

by:cathalmchale
Comment Utility
Also i would like a bit of space between the left panel -> the divider -> the right panel.  how do i do this??
0
 
LVL 18

Expert Comment

by:armoghan
Comment Utility
To make space use setDividerSize();
0
 

Author Comment

by:cathalmchale
Comment Utility
tried calling revalidate()  it didnt work. I will check back later, thanks
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:cathalmchale
Comment Utility
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
 

Author Comment

by:cathalmchale
Comment Utility
???
0
 
LVL 37

Accepted Solution

by:
zzynx earned 50 total points
Comment Utility
>>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
 
LVL 37

Expert Comment

by:zzynx
Comment Utility
Thanks for accepting

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

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now