实验代码:
package day1;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
@SuppressWarnings("unused")
public class Ww1{
public static void main(String[] args) {
JFrame jf1=new JFrame("个人简历");
jf1.getContentPane().setLayout(new FlowLayout());
jf1.getContentPane().add(new JLabel("你的姓名"));
jf1.getContentPane().add(new JTextField(20));
jf1.getContentPane().add(new JLabel("性别"));
JRadioButton j2=new JRadioButton("女");
jf1.getContentPane().add(new JLabel(" "));
JRadioButton j3=new JRadioButton("男");
jf1.add(j2);
jf1.add(j3);
jf1.getContentPane().add(new JLabel("民族"));
jf1.getContentPane().add(new JTextField(20));
jf1.getContentPane().add(new JLabel("出生年月"));
jf1.getContentPane().add(new JTextField(20));
jf1.getContentPane().add(new JLabel("联系电话"));
jf1.getContentPane().add(new JTextField(20));
jf1.getContentPane().add(new JLabel("通讯地址"));
jf1.getContentPane().add(new JTextField(20));
jf1.getContentPane().add(new JLabel("你的毕业学校"));
jf1.getContentPane().add(new JTextField(20));
jf1.getContentPane().add(new JLabel("个人优点"));
jf1.getContentPane().add(new JTextField(20));
jf1.getContentPane().add(new JLabel("想从事的职业"));
jf1.getContentPane().add(new JTextField(20));
jf1.getContentPane().add(new JLabel("你学的专业和会的专业"));
jf1.getContentPane().add(new JLabel("从以下选择"));
jf1.getContentPane().add(new JLabel("网络工程"));
jf1.getContentPane().add(new JRadioButton("是"));
jf1.getContentPane().add(new JLabel("物联网工程"));
jf1.getContentPane().add(new JRadioButton("是"));
jf1.getContentPane().add(new JLabel("软件工程"));
jf1.getContentPane().add(new JRadioButton("是"));
jf1.getContentPane().add(new JLabel("计算机科学与技术"));
jf1.getContentPane().add(new JRadioButton("是"));
jf1.setLayout(new GridLayout(15,2));
jf1.setSize(500, 400);
jf1.setVisible(true);
}
}
实验结果:
实验心得:每次做实验必须要认真,完成一个小模块然后加深,循序渐进。
package day1;import java.awt.FlowLayout;import java.awt.GridLayout;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JMenu;import javax.swing.JMenuItem;import javax.swing.JRadioButton;import javax.swing.JTextField;@SuppressWarnings("unused")public class Ww1{public static void main(String[] args) {JFrame jf1=new JFrame("个人简历");jf1.getContentPane().setLayout(new FlowLayout());jf1.getContentPane().add(new JLabel("你的姓名"));jf1.getContentPane().add(new JTextField(20));jf1.getContentPane().add(new JLabel("性别"));JRadioButton j2=new JRadioButton("女");jf1.getContentPane().add(new JLabel(" "));JRadioButton j3=new JRadioButton("男");jf1.add(j2);jf1.add(j3);jf1.getContentPane().add(new JLabel("民族"));jf1.getContentPane().add(new JTextField(20));jf1.getContentPane().add(new JLabel("出生年月"));jf1.getContentPane().add(new JTextField(20));jf1.getContentPane().add(new JLabel("联系电话"));jf1.getContentPane().add(new JTextField(20));jf1.getContentPane().add(new JLabel("通讯地址"));jf1.getContentPane().add(new JTextField(20));jf1.getContentPane().add(new JLabel("你的毕业学校")); jf1.getContentPane().add(new JTextField(20));jf1.getContentPane().add(new JLabel("个人优点"));jf1.getContentPane().add(new JTextField(20));jf1.getContentPane().add(new JLabel("想从事的职业"));jf1.getContentPane().add(new JTextField(20));jf1.getContentPane().add(new JLabel("你学的专业和会的专业"));jf1.getContentPane().add(new JLabel("从以下选择"));jf1.getContentPane().add(new JLabel("网络工程"));jf1.getContentPane().add(new JRadioButton("是"));jf1.getContentPane().add(new JLabel("物联网工程"));jf1.getContentPane().add(new JRadioButton("是"));jf1.getContentPane().add(new JLabel("软件工程"));jf1.getContentPane().add(new JRadioButton("是"));jf1.getContentPane().add(new JLabel("计算机科学与技术"));jf1.getContentPane().add(new JRadioButton("是"));jf1.setLayout(new GridLayout(15,2));jf1.setSize(500, 400);jf1.setVisible(true);}
}