I think this does what you want:
import java.awt.Dimension;
import javax.swing.*;
public class LayoutDemo extends JFrame {
private JSplitPane splitPane;
private JButton leftBtn;
private JButton rightBtn;
/** Creates new form LayoutDemo */
public LayoutDemo() {
initComponents();
setSize(300,400);
setLocationRelativeTo(null);
}
private void initComponents() {
getContentPane().add(getSplitPane(), java.awt.BorderLayout.CENTER);
pack();
}
public static void main(String args[]) {
new LayoutDemo().setVisible(true);
}
private JSplitPane getSplitPane() {
if (splitPane==null) {
splitPane = new JSplitPane();
splitPane.setOneTouchExpandable(true);
splitPane.setResizeWeight(0.5);
splitPane.setLeftComponent(getLeftBtn());
splitPane.setRightComponent(getRightBtn());
splitPane.setDividerLocation(1000);
}
return splitPane;
}
private JButton getLeftBtn() {
if (leftBtn==null) {
leftBtn = new JButton("LEFT");
leftBtn.setMinimumSize(new Dimension(0,0));
}
return leftBtn;
}
private JButton getRightBtn() {
if (rightBtn==null) {
rightBtn = new JButton("RIGHT");
rightBtn.setMinimumSize(new Dimension(0,0));
}
return rightBtn;
}
}
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54:





by: avlPosted on 2009-09-17 at 11:07:57ID: 25359127
PS: if an answer comes within a few days, I'll give more than the currently assigned 250 points.