Solved

JSplitter won't shrink JScrollPane

Posted on 2002-06-27
12
1,031 Views
Last Modified: 2007-11-27
I have a JTree inside of a JScrollPane and the JScrollPane on the left side of a JSplitter.  The problem is that the JSplitter won't shrink the JScrollPane below the point where text will be hidden in my JTree.  I want the splitter to be free to hide the text of the JTree as long as the JScrollPane will show the appropriate scroll bars.

Thanks
0
Comment
Question by:wgilster
  • 6
  • 5
12 Comments
 
LVL 92

Expert Comment

by:objects
Comment Utility
Pardon my ignorance, but what is a JSplitter?

Try changing the preferred minimum size of your tree or scroller.
0
 
LVL 1

Author Comment

by:wgilster
Comment Utility
I should have called it by the right name "JSplitPane".  So do I have to set the minimum size and perferred size for both the tree and the scroller?  I have already set the minimum for the JTree, I don't see why the scroller would have a significant impact but I'll try it.
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
>  I have already set the minimum for the JTree

What is it set to?
0
 
LVL 1

Author Comment

by:wgilster
Comment Utility
Everything seems to work alright when I set the minimum on the ScrollPane ONLY which will work for me.  Things start going a little wierd if I set the minimums on both the JTree and JScrollPane to 1.  For instance the ScrollPane doesn't show the scroll bars at the right times, and when it does, the scrollbars don't have enough room to scroll the whole JTree.  Oh well, I guess.  One last question before you get the points.  Is there a number that I can setMinimum() or setMaximum() that basically means there is no min or max?

Thanks a bunch.
0
 
LVL 3

Expert Comment

by:randyd
Comment Utility
I think you should just delete references to setMinimum meaning dont constrict to a minimum...

I think the fewer things you set the better off you'll be in terms of default behavior.

randy
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
> Is there a number that I can setMinimum() or
> setMaximum() that basically means there is no min or max?

As randyd suggests just don't set them.
Typically you should only need to be explicitly setting these values if you have a specific requirement to.

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:wgilster
Comment Utility
Perhaps then I'm using an old version of swing, because there is already preset minimums that exist for the JTree.  As I said, if I don't set a minimum, it automatically defaults to become the longest TreeNode text visible in the scrollbar view.  I don't know where this undesired behavior is coming from?
0
 
LVL 1

Author Comment

by:wgilster
Comment Utility
My problems aren't over, now I'm having the same problem with the other side(right side) of my JSplitPane.  I have got a bunch of JButtons in a "FlowLayouted Panel".  This "FlowLayouted Panel" is put into the NORTH side of another "BorderLayouted Panel", and that Panel is put into the right side of the JSplitPane.  Yes, it's kindof like a toolbar over the right side of the JSplitPane.  
Anyway, here is the strange part.  The more JButtons I add to my "BorderLayouted Panel" the shorter I am able to extend my JSplitPanel to the right.  Keep in mind that none of my JButtons have setMinimum() set.  Am I going to have to set the minimums for all of the JButtons to 1?  Something isn't working right.  It seems like a property of my splitter is trying to fit everything on the screen when I don't want it to.  Any ideas guys?
0
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
Comment Utility
If you don't explicitly set the minimum size then the UI is queried for the minimum size. I think the base UI for a button defines the minimum size to be the same as the preferred size so this would explain what you are experiencing.
Try putting the left hand panel in a scroll pane, or setting it minimum size.
0
 
LVL 1

Author Comment

by:wgilster
Comment Utility
I see.  That whole idea makes sense as an option based on some property, but I don't know if I like it as the default option.  I found that I have been mixing a couple AWT components with my Swing.  Would that have anything to do with it?
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
> but I don't know if I like it as the default option.

You don't like what default option?

You shouldn't mix AWT and Swing components.
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
powerN  challenge 3 46
What is the latest versions eclipse neon 2 113
java  and programming certification ? 4 62
@SBGen Method 3 25
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…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

763 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

7 Experts available now in Live!

Get 1:1 Help Now