JScrollPane & JFrame resize problem

Is there a possibility to know the difference between a user changing the divider location of a splitpane and the user
changing the framesize so that the divider location changes accordingly?

The problem is as follows:

I have added several nested vertically split JSplitPanes to a frame. The user must be able to change the divider location.
But when I resize the frame, the dividerlocation must stay the same. To accomplish this, I have added the JSplitPane
containing all the other SplitPanes to a JScrollPane. This ScrollPane works, but only after the minimum height of each
JSplitPane has been reached (ic. the height of a JLabel on it). What I want to achieve is that the user can change the
dividerlocations when he wants to, but that they stay the same when he resizes the frame.
I thought of saving the divider location when the user changed the location and then resetting it in the repaint() method.
When the user resizes the frame it should only get the previous divider locations and reset them.

I have started to override the repaint() but I need to know the difference between the frame resizing and the user dragging the divider location.

public void repaint () {
     try {
          if (jsp != null) { // jsp is the JScrollPane
               JSplitPane split = null, parentSplit;
               // go to the inner nested JSplitPane
               split = (JSplitPane) first.getBottomComponent();
               do {
                    split = (JSplitPane) split.getBottomComponent();
               } while ( split.getBottomComponent() instanceof JSplitPane);

               // get the parent and set the divider location
               parentSplit = (JSplitPane) split.getParent();
               do {
                    split.setDividerLocation ( /*preferredLocation */);
                    try {
                         parentSplit = (JSplitPane) parentSplit.getParent ();
//                         Print.pln("dividerlocation "+parentSplit.getDividerLocation ());
                    } catch (ClassCastException cce) { break; }
               } while ( parentSplit instanceof JSplitPane);
     } catch (Exception e) { Print.pln ("SplitPaneDesign exception :"+e); }

Is this possible?

Thanks for any help!

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


can't you just set the resizeWeight on all your splitpanes to 0.0d?

That way, the left/top component will not resize when the window does...

Maybe I've got the wrong end of the stick though...

JSplitPane.setResizeWeight( double weight ) ;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.