Link to home
Start Free TrialLog in
Avatar of s_lavie
s_lavie

asked on

problem with JSplitPane.

Hi,
I want a JFrame (which contains a JSplitPane) to have a JTable on its top, and a JTextArea on its bottom, but for some reason when running the program, I can only see the JTable. I can see the JSplitPane's divider under the JTable, but I can't move it with the mouse.

follwing the relevant code (in the JFrame constructor):
    getContentPane().add(JScrollPane1);
    getContentPane().add(JScrollPane2);
    JScrollPane1.getViewport().add(JTable1);
    JScrollPane2.getViewport().add(JTextArea1);
    JSplitPane1.setTopComponent(JScrollPane1);
    JSplitPane1.setBottomComponent(JScrollPane2);
    // for all components Autoscrolls = true.

Do you see any problem with that code? is something crucial missing?
Can you post me a code that do what I want smoothly?
BTW I'm using VCafe 3 (if its matter).

Thanks
Avatar of mwibbels
mwibbels

                   getContentPane().add(JScrollPane1);

and
                    JSplitPane1.setTopComponent(JScrollPane1);

Why are you adding the scrollpanes to both the JFrame and the JSplitPane. I think you should remove the 'getContentPane().add(JScrollPane1);' and 'getContentPane().add(JScrollPane2);' lines. And you should probably add the line

getContentPane().add(JSplitPane1)
Someone else asked a question similar to this where they could not programically  move the divider.  
I mentioned that the divider does not allow a component to be smaller than its minimum size.  Alot of times you have to manually set the minimum size of the top and bottom components to allow the divider to move.
However in the particular question that I mentioned it was not the problem.  But it something you could maybe try.
Good Luck
Avatar of s_lavie

ASKER

mwibbels,
getContentPane().add(JScrollPane1);
getContentPane().add(JScrollPane2);
its a code that was added by VCafe, I removed those lines, but no help.

conick, I know I get minimum divider location (=27 in the program). Is that what you meant??? how can I set minimum divider location?
 
Have any of you programed such a program, and it worked? Maybe its a VCafe bug?

Avatar of s_lavie

ASKER

Hi conick,
I understand now, you meant
> the minimum size of the top and bottom components
I didn't notice that before, but it did help.
Thanks a lot, post an answer and get your points.
ASKER CERTIFIED SOLUTION
Avatar of conick
conick

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial