Solved

JSplitter won't shrink JScrollPane

Posted on 2002-06-27
12
1,038 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tomcat administrtor 12 68
Convert from a json string array to a Java object 3 64
junit as external jar or library 7 40
learn programming 8 72
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 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…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

726 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