Re: Split Pane -> Getting equal pane sizes

Gregg Wonderly <[email protected]>
Newsgroups gmane.comp.java.netbeans.user-interface
Message-ID <[email protected]>

appleGuy wrote:
> yes ive tried to make both sides have panels that are the same size and
> positions etc. Still doesnt seem to work.
> 
> How to you define the divider as static, what does it mean?..Does it mean I
> cant change the divide by hand. If so I want to do this, but keep the
> proportions (equal at start of window) the same all the way through a
> resize.

I haven't seen all this discussion and I haven't tried the following, but this 
is what comes to mind for where to start.

There are two ways to specify the divider location on JSplitPane.  One is the 
absolute pixel position, the other is a floating point percentage.  By tracking 
the floating point percentage as the divider is moved, you can then know what 
percentage to use to position the bar on a resize.  I'd suggest that after 
installing a component listener to see the reshape start and end and making sure 
you understand that, then you should be able to do

// at some class level
double pos;

// When the divider location changes.
pos = jsp.getSize().width()/(double)jsp.getDividerLocation();

// As each resize happens
jsp.setDividerLocation(pos);

Gregg Wonderly
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.