Java 界面设计
就是一个界面分成两份但是不是固定大小可用鼠标来拖动(一个变大另一个变小)如图所示:用Java哪个控件实现...
就是一个界面分成两份 但是不是固定大小 可用鼠标来拖动(一个变大另一个变小)如图所示:
用Java 哪个控件实现 展开
用Java 哪个控件实现 展开
2个回答
展开全部
import java.awt.GridBagLayout;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import java.awt.GridBagConstraints;
public class Test1 extends JPanel {
private static final long serialVersionUID = 1L;
private JSplitPane jSplitPane = null;
/**
* This is the default constructor
*/
public Test1() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.fill = GridBagConstraints.BOTH;
gridBagConstraints.gridy = 0;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.gridx = 0;
this.setSize(300, 200);
this.setLayout(new GridBagLayout());
this.add(getJSplitPane(), gridBagConstraints);
}
/**
* This method initializes jSplitPane
*
* @return javax.swing.JSplitPane
*/
private JSplitPane getJSplitPane() {
if (jSplitPane == null) {
jSplitPane = new JSplitPane();
}
return jSplitPane;
}
}
楼主是不是要这种的效果???
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import java.awt.GridBagConstraints;
public class Test1 extends JPanel {
private static final long serialVersionUID = 1L;
private JSplitPane jSplitPane = null;
/**
* This is the default constructor
*/
public Test1() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.fill = GridBagConstraints.BOTH;
gridBagConstraints.gridy = 0;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.gridx = 0;
this.setSize(300, 200);
this.setLayout(new GridBagLayout());
this.add(getJSplitPane(), gridBagConstraints);
}
/**
* This method initializes jSplitPane
*
* @return javax.swing.JSplitPane
*/
private JSplitPane getJSplitPane() {
if (jSplitPane == null) {
jSplitPane = new JSplitPane();
}
return jSplitPane;
}
}
楼主是不是要这种的效果???
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询