importjava.awt.Checkbox;importjava.awt.CheckboxGroup;importjava.awt.Toolkit;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjavax.swing.ButtonG...
import java.awt.Checkbox;
import java.awt.CheckboxGroup;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
public class View extends JFrame{
int width = Toolkit.getDefaultToolkit().getScreenSize().width;
int height = Toolkit.getDefaultToolkit().getScreenSize().height;
JLabel JLname=new JLabel();
JLabel JLsex=new JLabel();
JLabel JLage=new JLabel();
JLabel JLbir=new JLabel();
JLabel JLnum=new JLabel();
JButton JBsure = new JButton();
JButton JBout = new JButton();
ButtonGroup btg = new ButtonGroup();//创建一个按钮组
JRadioButton nan = new JRadioButton("男");//创建两个单选框
JRadioButton nv = new JRadioButton("女");
JTextField JFname = new JTextField();
JTextField JFbir = new JTextField();
JTextField JFage = new JTextField();
JTextField JFnum = new JTextField();
public View(){
this.setLayout(null);
JLname.setText("姓名:");
JLname.setBounds(35,25,70,15);
this.add(JLname);
JLsex.setText("性别:");
JLsex.setBounds(180,25,70,15);
this.add(JLsex);
JLage.setText("年龄:");
JLage.setBounds(35,80,70,15);
this.add(JLage);
JLbir.setText("出生日期:");
JLbir.setBounds(150,80,70,15);
this.add(JLbir);
JLnum.setText("学号:");
JLnum.setBounds(35,135,70,15);
this.add(JLnum);
this.setTitle("添加");
JFname.setBounds(70,25,80,16);
this.add(JFname);
JFage.setBounds(70,80,50,16);
this.add(JFage);
JFbir.setBounds(215,80,80,16);
this.add(JFbir);
JFnum.setBounds(70,135,80,16);
this.add(JFnum);
btg.add(nan);//把nan单选框加入到btg组中
btg.add(nv);
this.add(nan);
this.add(nv);
nan.setBounds(280,25,50,16);
nv.setBounds(220,25,50,16);
JBsure.setBounds(0,180,355,30);
JBsure.setText("添加");
this.add(JBsure);
JBout.setBounds(0,210,355,30);
JBout.setText("重写");
this.add(JBout);
this.setSize(355, 380);
this.setLocation((width - 355) / 2, (height - 380) / 2);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
}
}
展开