JScrollPane & JFrame resize problem

Posted on 2003-03-30
Medium Priority
Last Modified: 2012-05-04
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!

Question by:bono_estente
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 35

Accepted Solution

TimYates earned 150 total points
ID: 8233547

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 ) ;

Expert Comment

ID: 9058398
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.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Suggested Courses
Course of the Month12 days, 10 hours left to enroll

777 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