JSpltpane resizing
hi all,
i have separated two panels using JSplitpane(VERTICAL_SPLIT)..
when i resize the splitpane the bottom panel is getting smaller.. but i want the bottom panel to be in same size and top panel size to be varied..
i tried by adding JSplitPane to the JScrollPane but scrollpane is not scrolling.
is there any solution for this ?
Any help will really be appreciated.
regards
suresh
[432 byte] By [
Suresh22a] at [2007-11-26 17:46:25]

# 3
sorry i confused u all..
actually my problem is, when i resize the splitpane its getting resize up to the bottom of the frame and not beyond that.. but what i need is, the splitpane should keep on growing and i should view it in scrollpane..
i tried by doing this...but its not working..
JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, bottomPanel);
JScrollPane scroll = new JScrollPane(split);
getContentPane().add(scroll);
is there anyother way of doing this ?
regards
suresh
# 5
i tried your example by changing thecomponent size, but the componet isn't growing..
import java.awt.*;
import java.beans.*;
import java.awt.event.*;
import javax.swing.*;
public class SplitPaneResizing_1 extends JFrame implements PropertyChangeListener
{
JSplitPane top;
JSplitPane down;
private javax.swing.JPanel detailPnl;
private javax.swing.JScrollPane detailScrlPane;
JPanel pnlTop;
public SplitPaneResizing_1()
{
JSplitPane main = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
getContentPane().add( main );
pnlTop = new JPanel();
JPanel pnlDown = new JPanel();
JScrollPane pane = new JScrollPane(pnlTop,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
main.setTopComponent( pane );
main.setBottomComponent( pnlDown );
top = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
top.setContinuousLayout(true);
pnlTop.add(top);
down = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
pnlDown.add(down);
top.setLeftComponent( createPanel(Color.RED) );
top.setRightComponent( createPanel(Color.GREEN) );
down.setLeftComponent( createPanel(Color.BLUE) );
down.setRightComponent( createPanel(Color.WHITE) );
// This code will keep the top/down scroll panes in sync
//
top.addPropertyChangeListener( this );
down.addPropertyChangeListener( this );
}
private JComponent createPanel(Color background)
{
JPanel panel = new JPanel();
panel.setPreferredSize( new Dimension(200, 100) );
panel.setBackground( background );
panel.add( new JLabel( background.toString() ) );
return new JScrollPane(panel);
}
public void propertyChange(PropertyChangeEvent e)
{
if ("dividerLocation".equals(e.getPropertyName()))
{
Object source = e.getSource();
JSplitPane target = (source.equals(top)) ? down : top;
int location = ((Integer)e.getNewValue()).intValue();
System.out.println(location);
if(location>=385)
{
pnlTop.setPreferredSize(new Dimension(pnlTop.getWidth()+30,pnlTop.getHeight()));
}
if (location != target.getDividerLocation())
target.setDividerLocation( location );
}
}
public static void main(String[] args)
{
SplitPaneResizing_1 frame = new SplitPaneResizing_1();
frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
frame.setSize(500, 300);
frame.setLocationRelativeTo( null );
frame.setVisible(true);
}
}