Solved

JSplitter won't shrink JScrollPane

Posted on 2002-06-27
12
1,034 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ForLoop Example 3 48
even odd program using while loop 3 40
spring jars download 1 26
going to wrong jsp page 2 19
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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…
This video teaches viewers about errors in exception handling.

813 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

18 Experts available now in Live!

Get 1:1 Help Now