我有两个拆分窗格..这里的代码..我想要的是不应该允许拖动垂直分隔线,它可以是可扩展的,但应该修复在提到的分隔线位置,一个应该不能我们通常可以使用鼠标向上或向下移动它,这是代码,我需要添加什么?
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);
}
}
答案 0 :(得分:0)
将添加到垂直JSplitPane(righJPanel和downJPanel)的组件的最小大小设置为您希望它们的大小。在这种情况下,因为您不允许调整帧的大小,所以会将分隔符锁定在指定的位置。