package ziwojieshao;
import java.awt.FlowLayout;
import javax.swing.*;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.*;
public class hello extends JFrame{
public hello()
{
JFrame test=new JFrame ("自我介绍");
test.setLayout(new GridLayout(0,2));
test.getContentPane().add(new JLabel("姓名")) ;
test.getContentPane().add(new JTextField("钟若文",8)) ;
test.getContentPane().add(new JLabel("性别")) ;
test.setSize(180,210);
test.getContentPane().add(new JTextField("男",2));
String proList[] = { "年龄","民族" ,"籍贯","学号","学院","专业"};
test.getContentPane().add(new JLabel(proList[0]));
test.getContentPane().add(new JTextField("20",2));
test.getContentPane().add(new JLabel(proList[1]));
test.getContentPane().add(new JTextField("汉族",4));
test.getContentPane().add(new JLabel(proList[2]));
test.getContentPane().add(new JTextField("湖南",4));
test.getContentPane().add(new JLabel(proList[3]));
test.getContentPane().add(new JTextField("20173311120",8));
test.getContentPane().add(new JLabel(proList[4]));
test.getContentPane().add(new JTextField("计算机学院",8));
test.getContentPane().add(new JLabel(proList[5]));
test.getContentPane().add(new JTextField("网络工程",8));
test.setVisible(true);
}
public static void main (String[] args) {
new hello();
}
}
原文地址:https://www.cnblogs.com/zrwhaha/p/11041749.html