我有两个分割窗格。这里是代码,我想要的是垂直分隔符不应该被拖拽,它可以扩展,但应该固定在提到的分隔符位置,一个不应该能够使用鼠标向上或向下移动它,因为我们通常可以,这里的代码,我需要添加什么??
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);
}
}
将添加到垂直JSplitPane(右jpanel和downJPanel)的组件的最小大小设置为您想要的大小。在这种情况下,因为你不允许调整帧的大小,这将有效果锁定分隔符在其指定的位置