Solved

JSplitter won't shrink JScrollPane

Posted on 2002-06-27
12
1,042 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
[X]
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
  • 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 Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 
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 50 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

Technology Partners: 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 first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

690 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