JSplitPane.setResizeWeight(int v)
试试

解决方案 »

  1.   

    本来 就不会移动吧
    package com.fxxc.test;import java.awt.BorderLayout;
    import java.awt.EventQueue;import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.border.EmptyBorder;public class FrameTest extends JFrame { private JPanel contentPane; /**
     * Launch the application.
     */
    public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
    public void run() {
    try {
    PanelTest panel = new PanelTest();
    FrameTest frame = new FrameTest();
    frame.add(panel);
    frame.setVisible(true);
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    });
    } /**
     * Create the frame.
     */
    public FrameTest() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 450, 300);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);
    }}
    package com.fxxc.test;import javax.swing.JPanel;
    import java.awt.GridBagLayout;
    import javax.swing.JSplitPane;
    import java.awt.GridBagConstraints;public class PanelTest extends JPanel { /**
     * Create the panel.
     */
    public PanelTest() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[]{0, 0};
    gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0};
    gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
    gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE};
    setLayout(gridBagLayout);

    JSplitPane splitPane = new JSplitPane();
    GridBagConstraints gbc_splitPane = new GridBagConstraints();
    gbc_splitPane.gridheight = 4;
    gbc_splitPane.fill = GridBagConstraints.BOTH;
    gbc_splitPane.gridx = 0;
    gbc_splitPane.gridy = 0;
    add(splitPane, gbc_splitPane);

    JSplitPane splitPane_1 = new JSplitPane();
    splitPane.setLeftComponent(splitPane_1); }}
      

  2.   

    如果你是想让c的大小不变的话,可以设置raiseweight为0或者1(试一下),然后设置diviserlocation为一个固定值