实验程序:
import java.awt.Font;
import javax.swing.*;
public class JL {
public static void main(String[] args) {
// TODO 自动生成的方法存根
JFrame frame=new JFrame("简历"); //创建窗体
JPanel p=new JPanel(); //创建面板
frame.add(p);
frame.setResizable(false); //不可拖动窗体
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setBounds(500,300,560,340);
import javax.swing.*;
public class JL {
public static void main(String[] args) {
// TODO 自动生成的方法存根
JFrame frame=new JFrame("简历"); //创建窗体
JPanel p=new JPanel(); //创建面板
frame.add(p);
frame.setResizable(false); //不可拖动窗体
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setBounds(500,300,560,340);
JTextField Field1=new JTextField(); //创建文本框
p.add(Field1);
JTextField Field2=new JTextField(); //创建文本框
p.add(Field2);
JTextField Field3=new JTextField(); //创建文本框
p.add(Field3);
JTextField Field4=new JTextField(); //创建文本框
p.add(Field4);
p.add(Field1);
JTextField Field2=new JTextField(); //创建文本框
p.add(Field2);
JTextField Field3=new JTextField(); //创建文本框
p.add(Field3);
JTextField Field4=new JTextField(); //创建文本框
p.add(Field4);
JLabel L1=new JLabel("姓 名:"); //创建标签
p.add(L1);
JLabel L2=new JLabel("性 别:");
p.add(L2);
JLabel L3=new JLabel("学院:");
p.add(L3);
JLabel L4=new JLabel("生日:");
p.add(L4);
JLabel L5=new JLabel("专业:");
p.add(L5);
JLabel L6=new JLabel("民 族:");
p.add(L6);
JLabel L7=new JLabel("籍 贯:");
p.add(L7);
JRadioButton r1=new JRadioButton("男"); //创建单选框
JRadioButton r2=new JRadioButton("女");
JRadioButton r3=new JRadioButton("计算机学院"); //创建单选框
JRadioButton r4=new JRadioButton("人文学院");
JRadioButton r5=new JRadioButton("数统学院"); //创建单选框
JRadioButton r2=new JRadioButton("女");
JRadioButton r3=new JRadioButton("计算机学院"); //创建单选框
JRadioButton r4=new JRadioButton("人文学院");
JRadioButton r5=new JRadioButton("数统学院"); //创建单选框
ButtonGroup group1=new ButtonGroup(); //创建一个组,将r1与r2放在一起
ButtonGroup group2=new ButtonGroup();
group1.add(r1);
group1.add(r2);
group2.add(r3);
group2.add(r4);
group2.add(r5);
p.add(r1);
p.add(r2);
p.add(r3);
p.add(r4);
p.add(r5);
frame.add(p);
JCheckBox box1=new JCheckBox("网络工程"); //创建复选框
JCheckBox box2=new JCheckBox("应用数学");
JCheckBox box3=new JCheckBox("汉语言文学");
JCheckBox box4=new JCheckBox("软件工程");
p.add(box1);
p.add(box2);
p.add(box3);
p.add(box4);
frame.add(p);
p.setLayout(null); //自定义组件位置
L1.setBounds(110,35,250,25);
L1.setFont(new Font("黑体",Font.BOLD,15)); //设置组件位置
L2.setBounds(110,60,90,30);
L2.setFont(new Font("黑体",Font.BOLD,15));
L3.setBounds(110,170,340,35);
L3.setFont(new Font("黑体",Font.BOLD,15));
L4.setBounds(110,140,140,25);
L4.setFont(new Font("黑体",Font.BOLD,15));
L5.setBounds(100,210,140,25);
L5.setFont(new Font("黑体",Font.BOLD,15));
L6.setBounds(110,115,340,25);
L6.setFont(new Font("黑体",Font.BOLD,15));
L7.setBounds(110,90,340,25);
L7.setFont(new Font("黑体",Font.BOLD,15));
L1.setFont(new Font("黑体",Font.BOLD,15)); //设置组件位置
L2.setBounds(110,60,90,30);
L2.setFont(new Font("黑体",Font.BOLD,15));
L3.setBounds(110,170,340,35);
L3.setFont(new Font("黑体",Font.BOLD,15));
L4.setBounds(110,140,140,25);
L4.setFont(new Font("黑体",Font.BOLD,15));
L5.setBounds(100,210,140,25);
L5.setFont(new Font("黑体",Font.BOLD,15));
L6.setBounds(110,115,340,25);
L6.setFont(new Font("黑体",Font.BOLD,15));
L7.setBounds(110,90,340,25);
L7.setFont(new Font("黑体",Font.BOLD,15));
r1.setBounds(200,60,90,30);
r2.setBounds(300,60,110,30);
r3.setBounds(170,172,110,40);
r4.setBounds(280,172,115,40);
r5.setBounds(390,172,130,40);
box1.setBounds(170,210,100,25);
box2.setBounds(270,210,100,25);
box3.setBounds(370,210,100,25);
box4.setBounds(470,210,100,25);
r2.setBounds(300,60,110,30);
r3.setBounds(170,172,110,40);
r4.setBounds(280,172,115,40);
r5.setBounds(390,172,130,40);
box1.setBounds(170,210,100,25);
box2.setBounds(270,210,100,25);
box3.setBounds(370,210,100,25);
box4.setBounds(470,210,100,25);
Field1.setBounds(170,35,250,22);
Field2.setBounds(170,140,250,22);
Field3.setBounds(170,90,250,22);
Field4.setBounds(170,115,250,22);
Field2.setBounds(170,140,250,22);
Field3.setBounds(170,90,250,22);
Field4.setBounds(170,115,250,22);
frame.setVisible(true); //设置窗体状态显示
}
}
}
实验结果: