package shx;
import javax.swing.*;
import java.awt.*;
public class sh extends JFrame{
JPanel jp1,jp2,jp3;
JLabel jlb1,jlb2;
JButton jb1,jb2;
JCheckBox jcb1,jcb2,jcb3;
JRadioButton jrb1,jrb2;
ButtonGroup bg;
public static void main(String[] args)
{
sh gui=new sh();
}
public sh()
{
jp1=new JPanel();
jp2=new JPanel();
jp3=new JPanel();
jlb1=new JLabel("你喜欢的运动");
jlb2=new JLabel("你的性别");
jb1=new JButton("注册用户");
jb2=new JButton("取消注册");
jcb1=new JCheckBox("足球");
jcb2=new JCheckBox("篮球");
jcb3=new JCheckBox("网球");
jrb1=new JRadioButton("男");
jrb2=new JRadioButton("女");
bg=new ButtonGroup(); //一定要将按钮放在一个组里
this.setLayout(new GridLayout(3,1));
jp1.add(jlb1);
jp1.add(jcb1);
jp1.add(jcb2);
jp1.add(jcb3);
jp2.add(jlb2);
jp2.add(jrb1);
jp2.add(jrb2);
bg.add(jb1);
bg.add(jb2);
jp3.add(jb1);
jp3.add(jb2);
this.add(jp1);
this.add(jp2);
this.add(jp3);
this.setSize(300,150);
this.setLocation(300,300);
this.setTitle("shabi");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
}
java【源码】注册小练习
最新推荐文章于 2023-06-06 22:53:55 发布