RadioButton控件怎么清空?按下“重置”按钮时界面能够跟图片一样
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class stu_xinxi extends JFrame implements ActionListener
{
JPanel jp=new JPanel();
JLabel jl=new JLabel("添加基本信息");
JLabel[] lab={new JLabel("学 号:"),new JLabel("姓 名:"),new JLabel("性 别:"),new JLabel("班 级:"),new JLabel("学 院:")};
JTextField[] jtf={new JTextField(8),new JTextField(8),new JTextField(8),new JTextField(8)};
JButton jb=new JButton("添加");
JButton jb1=new JButton("重置");
JRadioButton[] jrb={new JRadioButton("男"),new JRadioButton("女")};
ButtonGroup bg=new ButtonGroup();
public stu_xinxi()
{
super("添加学生信息");
jp.setLayout(null);
this.add(jp);
this.setBounds(400,200,400,400);
jl.setBounds(150,40,100,20);
jp.add(jl);
for(int i=0;i
{
lab[i].setBounds(100,40*(i+2),100,20);
jp.add(lab[i]);
}
for(int i=0;i
{
if(i==2||i==3)
{
jtf[i].setBounds(200,40*(i+3),100,20);
jp.add(jtf[i]);
}
else
{
jtf[i].setBounds(200,40*(i+2),100,20);
jp.add(jtf[i]);
}
}
for(int i=0;i
{
jrb[i].setBounds(200+(i*50),160,50,20);
jp.add(jrb[i]);
}
jb1.addActionListener(this);
jb.setBounds(120,280,70,20);
jp.add(jb);
jb1.setBounds(220,280,70,20);
jp.add(jb1);
for(int i=0;i
{
bg.add(jrb[i]);
}
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==jb1)
{
for(int i=0;i
{
jtf[i].setText(null);
}
//for(int i=0;i
//{
// jrb[i].setSelected(false);
//}
}
}
public static void main(String[] args)
{
stu_xinxi xx=new stu_xinxi();
}
}