Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

JSplitter won't shrink JScrollPane

Posted on 2002-06-27
12
Medium Priority
?
1,050 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
ID: 7115411
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
ID: 7116959
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
ID: 7117547
>  I have already set the minimum for the JTree

What is it set to?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:wgilster
ID: 7121745
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
ID: 7121889
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
ID: 7123348
> 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
 
LVL 1

Author Comment

by:wgilster
ID: 7124612
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
ID: 7124829
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 200 total points
ID: 7125490
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
ID: 7127226
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
ID: 7128275
> 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
ID: 7139071
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month21 days, 5 hours left to enroll

810 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