import javax.print.DocFlavor.URL;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import java.net.URI;
public class SwingAppProgram extends JFrame{
public SwingAppProgram(){
setTitle("我的窗体");
setBounds(100,100,340,500);
this.createUi();
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void createUi(){
//new SwingAppProgram();
JPanel panel = new JPanel();
Border border = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
TitledBorder tBorder = BorderFactory.createTitledBorder(border,"注册面板",
TitledBorder.CENTER,TitledBorder.TOP);
panel.setBorder(tBorder);
panel.setLayout(null);
this.add(panel);
//姓名
JLabel nameLb1 = new JLabel("输入姓名:");
nameLb1.setBounds(10, 50, 60, 25);
panel.add(nameLb1);
JTextField nameTxt = new JTextField();
nameTxt.setBounds(80, 50, 120, 22);
panel.add(nameTxt);
//密码
JLabel pwdbl = new JLabel("输入密码:");
pwdbl.setBounds(10, 80, 60, 25);
panel.add(pwdbl);
JPasswordField pwd = new JPasswordField();
pwd.setBounds(80,80,120,22);
panel.add(pwd);
//性别
JLabel genderLb1 = new JLabel();
genderLb1.setBounds(10,110, 60, 25);
panel.add(genderLb1);
ButtonGroup group = new ButtonGroup();
JRadioButton fRdo = new JRadioButton("男",true);
fRdo.setBounds(80,110, 50, 25);
group.add(fRdo);
JRadioButton mRdo = new JRadioButton("女",false);
mRdo.setBounds(140, 110, 50, 25);
group.add(mRdo);
group.add(fRdo);
panel.add(mRdo);
//学历
JLabel ediLb1 = new JLabel("学历:");
ediLb1.setBounds(10, 140, 60, 25);
panel.add(ediLb1);
//下拉列表
JComboBox edicbo = new JComboBox();
edicbo.addItem("高中");
edicbo.addItem("大专");
edicbo.addItem("大专");
edicbo.addItem("其他");
edicbo.setBounds(80, 140, 80, 22);
panel.add(edicbo);
//爱好
JLabel hobbyLb1 = new JLabel("爱好!");
hobbyLb1.setBounds(10, 170, 60, 25);
panel.add(hobbyLb1);
//复选框
JCheckBox hobbyChk = new JCheckBox("睡觉");
hobbyChk.setBounds(80, 170, 60, 25);
panel.add(hobbyChk);
JCheckBox hobbyCh2 = new JCheckBox("运动",true);
hobbyCh2.setBounds(150, 170, 60, 25);
panel.add(hobbyCh2);
JCheckBox hobbyCh3 = new JCheckBox("爬山");
hobbyCh3.setBounds(220, 170, 60, 25);
panel.add(hobbyCh3);
//自我介绍
JLabel intrLb1 = new JLabel("自我介绍:");
intrLb1.setBounds(10, 200, 60, 25);
panel.add(intrLb1);
//Swing 中文本域默认是不带滚动条的,必须放置在JScrollpane中,才会有滚动条出现
JTextArea intrArea = new JTextArea();