Solved

split pane problem

Posted on 2001-08-29
12
224 Views
Last Modified: 2010-08-05
Hi,
I have a JSpiltpane  with horizontal orientation

I have set oneTouchExpandable property of splitpane to true

But When the user presses the down arrow control
I still want a minimum size of the bottom component
to be seen.

How do I do this
because right now clicking on the down arrow
hides the entire bottom component

some code will be helpful

0
Comment
Question by:sanjay_thakur
12 Comments
 
LVL 6

Expert Comment

by:kotan
ID: 6438997
You have a lot of question in "unlockedq" status.
Are you going to do the same on this question?
   
Questions Asked : 39
Last 10 Grades Given : B B B B B B B B B A
Question Grading Record : 16 Answers Graded / 16 Answers Received

We only help those people are responsible
0
 
LVL 4

Author Comment

by:sanjay_thakur
ID: 6439018
hey
I am not the only one who is using this account
There is a whole group .
I hope you can understand  now why it is like this

Anyways I have asked every one to grade the questions
and to be responsible.

Thanks for the consideration anyway

0
 
LVL 4

Expert Comment

by:sdussinger
ID: 6439029
If that's the case, maybe it would be a good idea to create your own account here. That way you wouldn't get lumped in with your irresponsible peers...

As for the question, use the following subclass for your split panes:

class MySplitPane extends javax.swing.JSplitPane
{
    private int bottomMinHeight = 100;
   
    public MySplitPane () { super (); }
   
    public int getBottomMinHeight ()
    {
        return (bottomMinHeight);
    }
   
    public void setBottomMinHeight (int height)
    {    
        bottomMinHeight = height >= 0 ? height : 0;
    }
   
    public void setDividerLocation (int loc)
    {
        if (loc > getHeight () - getDividerSize () - getBottomMinHeight ())
            super.setDividerLocation (getHeight () - getDividerSize () - getBottomMinHeight ());
        else
            super.setDividerLocation (loc);
    }
}


This sets a default of 100 pixels as the minimum height for the bottom pane.

You can change this minimum height by calling the setBottomMinHeight () method.

HTH

--Steve
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 92

Expert Comment

by:objects
ID: 6439710
So do u use ee as your business's help desk?
0
 
LVL 4

Author Comment

by:sanjay_thakur
ID: 6441349
for objects,
No but what do you expect from a bunch of students.

I just helped them by giving them the access.

I have already said I will work it up.

Is little bit consideration too much to ask for?

0
 
LVL 4

Author Comment

by:sanjay_thakur
ID: 6441912
for sdussigner
Hi, I am able to keep a minimum size for split pane but it has changed somethings

1) I had set divider size to some int value
like splitpane.setDividerSize(divSize);

by when the screen initially shows up i think
it still takes the default size of the divider
only if I click on the divider I get the size
which I have set.

How do I enforce a minimum size for the divider?

2) when I use the arrow buttons.it somehow
doesnot go to the previous divider location
I mean whenevr I click the up arrow it completely
hides the top component no matter
where the divider is.

Ideally when you click the up arrow it goes back
to the previous divider location

I tried using  splitPane.setLastDividerLocation(value);
but doesnot work

Any help ?

















0
 
LVL 4

Author Comment

by:sanjay_thakur
ID: 6441917
for sdussigner
Hi, I am able to keep a minimum size for split pane but it has changed somethings

1) I had set divider size to some int value
like splitpane.setDividerSize(divSize);

but when the screen initially shows up i think
it still takes the default size of the divider
only if I click on the divider I get the size
which I have set.

How do I enforce a minimum size for the divider?

2) when I use the arrow buttons.it somehow
doesnot go to the previous divider location
I mean whenever I click the up arrow it completely
hides the top component no matter
where the divider is.

Ideally when you click the up arrow it goes back
to the previous divider location

I tried using  splitPane.setLastDividerLocation(value);
but doesnot work

Any help ?

p.s:has this anything to do with restricting
the size of the bottom component















0
 
LVL 4

Expert Comment

by:sdussinger
ID: 6442011
1) I can't duplicate this. When I set the divider size to 30, it showed up on the screen immediately.

2) The problem here is that the code needed to do this would interfere with the dragging of the divider. The code to handle the moving of the divider is in the Swing L&F code itself. This code doesn't indicate to the JSplitPane whether the moving is being done by dragging or by clicking on the butons. If we put the code in here to handle the click case, then the drag case would break, since we can't tell them apart.  I put the code in to test it, and the click case works, but the drag case fails horribly.

The only other solution is to subclass the L&F code to get the behavior, but this would be a lot of work for potentially little gain...

--Steve
0
 
LVL 4

Author Comment

by:sanjay_thakur
ID: 6454020
Hi steve
Sorry for replying late

I am not able to set the divider to the
size I need.

My question is if the components (top and bottom component)
have a box layout and the maximum size is
set to the screensize

then It will affect the divider's size.
Is there any way to define a minimum size for the divider

I dont think ther is an API.Is there any workaround?




0
 
LVL 4

Expert Comment

by:sdussinger
ID: 6454337
In the MySplitPane class, override getDividerSize ().

public void getDividerSize () { return (30); }

This worked for me (of course, calling setDividerSize on the split pane worked for me, as well :-))...

HTH

--Steve
0
 
LVL 4

Accepted Solution

by:
sdussinger earned 15 total points
ID: 6454345
I really need to proof my stuff, before I post it.

Of course the getDividerSize method in the previous needs to return an int, not be void...

public int getDividerSize () { return (30); }

--Steve
0
 
LVL 4

Author Comment

by:sanjay_thakur
ID: 6454655
Thanks.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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:
The viewer will learn how to implement Singleton Design Pattern in Java.

808 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