split pane problem

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

LVL 4
sanjay_thakurAsked:
Who is Participating?
 
sdussingerCommented:
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
 
kotanCommented:
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
 
sanjay_thakurAuthor Commented:
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
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
sdussingerCommented:
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
 
objectsCommented:
So do u use ee as your business's help desk?
0
 
sanjay_thakurAuthor Commented:
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
 
sanjay_thakurAuthor Commented:
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
 
sanjay_thakurAuthor Commented:
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
 
sdussingerCommented:
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
 
sanjay_thakurAuthor Commented:
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
 
sdussingerCommented:
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
 
sanjay_thakurAuthor Commented:
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.