0

我有两个拆分窗格..这是代码..我想要的是垂直分隔线不应该被拖动,它可以扩展,但应该固定在提到的分隔线位置,一个不应该能够移动它我们通常可以向上或向下使用鼠标,这是代码,我需要添加什么?

package Arrears;

import UI.UILabel;
import UI.UIPanel;
import ebg.MainApp;
import java.awt.BorderLayout;
import javax.swing.JInternalFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JSplitPane;


public class swingMenu extends JInternalFrame
{
    JMenuBar mbar;

    JMenu fileMenu;
    JMenu helpMenu;

    JMenuItem openFileMenuItem;
    JMenuItem exitFileMenuItem;

    JSplitPane horiSplitPane;
    JSplitPane verSplitPane;

    UIPanel horiJPanel;
    UIPanel righJPanel;
    UIPanel downJPanel;

    UILabel side;
    UILabel right;
    UILabel down;
    public swingMenu(MainApp This)
    {
        super("");

        side=new UILabel("side");
        right=new UILabel("right");
        down=new UILabel("down");

        mbar=new JMenuBar();

        fileMenu=new JMenu("File");
        helpMenu=new JMenu("Help");

        openFileMenuItem=new JMenuItem("Open");
        exitFileMenuItem=new JMenuItem("Exit");

        fileMenu.add(openFileMenuItem);
        fileMenu.add(exitFileMenuItem);

        mbar.add(fileMenu);
        mbar.add(helpMenu);

        horiJPanel=new UIPanel();
        horiJPanel.setLayout(new BorderLayout());
        horiJPanel.add(right);

        righJPanel=new UIPanel();
        righJPanel.setLayout(new BorderLayout());
        righJPanel.add(right);

        downJPanel=new UIPanel();
        downJPanel.setLayout(new BorderLayout());
        downJPanel.add(right);

        verSplitPane= new JSplitPane(JSplitPane.VERTICAL_SPLIT, righJPanel,downJPanel);
        verSplitPane.setOneTouchExpandable(true);
        verSplitPane.setResizeWeight(0.8);
        verSplitPane.setDividerLocation(360);

        horiSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, horiJPanel, verSplitPane);
        horiSplitPane.setOneTouchExpandable(true);
        horiSplitPane.setResizeWeight(0.2);
        horiSplitPane.setDividerLocation(120);

        getContentPane().add(horiSplitPane);

        setResizable(false);
        setMaximizable(true);
        setIconifiable(true);
        setClosable(true);
        setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
        setSize(550,500);
        setLocation(280, 80);
        setVisible(true);
        setOpaque(true);
        setJMenuBar(mbar);
    }
}
4

1 回答 1

0

将添加到垂直 JSplitPane(righJPanel 和 downJPanel)的组件的最小尺寸设置为您想要的尺寸。在这种情况下,因为您不允许调整框架的大小,这将产生将分隔线锁定在其指定位置的效果。

于 2013-05-22T12:51:53.457 回答