import java.awt.*;
import javax.swing.*;
public class GridBagLayoutDemo extends JFrame {
public GridBagLayoutDemo() { //构造函数
Container contentPane = getContentPane(); //得到容器
contentPane.setLayout(new GridBagLayout()); //设置布局管理器
JLabel labelName=new JLabel("姓名"); //姓名标签
JLabel labelSex=new JLabel("性别"); //性别标签
JLabel labelAddress=new JLabel("住址"); //住址标签
JTextField textFieldName = new JTextField(); //性名文本域
JTextField textFieldAddress = new JTextField(); //地址文本域
JComboBox comboBoxSex = new JComboBox(); //性别组合框
comboBoxSex.addItem("男"); //增加选择项
comboBoxSex.addItem("女");
JButton buttonConfirm=new JButton("确定"); //确定按钮
JButton buttonCancel=new JButton("退出"); //退出按钮
//增加各个组件
contentPane.add(labelName, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0));
contentPane.add(textFieldName, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0));
contentPane.add(comboBoxSex, new GridBagConstraints(3, 0, 1, 1, 1.0, 0.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0));
contentPane.add(labelSex, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 0), 0, 0));
contentPane.add(buttonConfirm, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 3, 0), 0, 0));
contentPane.add(buttonCancel, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 0, 3, 0), 0, 0));
contentPane.add(labelAddress, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0));
contentPane.add(textFieldAddress, new GridBagConstraints(1, 1, 3, 1, 0.0, 0.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0));
setTitle("GridBagLayout 演示"); //设置窗口标题
setSize(300,140); //设置窗口尺寸
setVisible(true); //设置窗口可见
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //关闭窗口时退出程序
}
public static void main(String args[]) {
new GridBagLayoutDemo();
}
}大家好.请问大虾们以上的那个括号里的数字是什么东西
import javax.swing.*;
public class GridBagLayoutDemo extends JFrame {
public GridBagLayoutDemo() { //构造函数
Container contentPane = getContentPane(); //得到容器
contentPane.setLayout(new GridBagLayout()); //设置布局管理器
JLabel labelName=new JLabel("姓名"); //姓名标签
JLabel labelSex=new JLabel("性别"); //性别标签
JLabel labelAddress=new JLabel("住址"); //住址标签
JTextField textFieldName = new JTextField(); //性名文本域
JTextField textFieldAddress = new JTextField(); //地址文本域
JComboBox comboBoxSex = new JComboBox(); //性别组合框
comboBoxSex.addItem("男"); //增加选择项
comboBoxSex.addItem("女");
JButton buttonConfirm=new JButton("确定"); //确定按钮
JButton buttonCancel=new JButton("退出"); //退出按钮
//增加各个组件
contentPane.add(labelName, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0));
contentPane.add(textFieldName, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0));
contentPane.add(comboBoxSex, new GridBagConstraints(3, 0, 1, 1, 1.0, 0.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0));
contentPane.add(labelSex, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 0), 0, 0));
contentPane.add(buttonConfirm, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 0, 3, 0), 0, 0));
contentPane.add(buttonCancel, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 0, 3, 0), 0, 0));
contentPane.add(labelAddress, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0));
contentPane.add(textFieldAddress, new GridBagConstraints(1, 1, 3, 1, 0.0, 0.0
,GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 5), 0, 0));
setTitle("GridBagLayout 演示"); //设置窗口标题
setSize(300,140); //设置窗口尺寸
setVisible(true); //设置窗口可见
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //关闭窗口时退出程序
}
public static void main(String args[]) {
new GridBagLayoutDemo();
}
}大家好.请问大虾们以上的那个括号里的数字是什么东西
解决方案 »
- 有没有介绍java class比如HashMap, Map 如何实现的书籍?
- JAVA 获取时间问题,非常技术贴---大侠,牛人请进
- null+str
- 重金悬赏100分求程序代码(文本文件中的单词统计)
- 高手帮忙,急!RMI问题:UnicastRemoteObject(int port)怎么用?
- 请问大虾:如果实现VC的group box效果?即是虚框的左上角有文字描述,在线等,最好有代码
- showInputDialog输入对话框的JTextField中如何带默认值,在线等待!
- 在java中如何模拟一段连续的内存空间———请各位大哥大姐不吝赐教
- 哪里有Java类和接口的中文帮助啊?
- 如何解决Java中部同类中变量的使用
- 麻烦各位大哥帮个忙,小女子谢过了。
- 请问各位老大在Debian Linux中,怎么设置jfreechart中文?现在显示都是框
public GridBagConstraints(int gridx,
int gridy,
int gridwidth,
int gridheight,
double weightx,
double weighty,
int anchor,
int fill,
Insets insets,
int ipadx,
int ipady)创建一个 GridBagConstraints 对象,将其所有字段都设置为传入参数。注:因为使用此构造方法会妨碍源代码的可读性,所以此构造方法仅供自动源代码生成工具使用。 参数:
gridx - 初始 gridx 值。
gridy - 初始 gridy 值。
gridwidth - 初始 gridwidth 值。
gridheight - 初始 gridheight 值。
weightx - 初始 weightx 值。
weighty - 初始 weighty 值。
anchor - 初始 anchor 值。
fill - 初始 fill 值。
insets - 初始 insets 值。
ipadx - 初始 ipadx 值。
ipady - 初始 ipady 值。
从以下版本开始:
1.2
另请参见:
gridx, gridy, gridwidth, gridheight, weightx, weighty, anchor, fill, insets, ipadx, ipady