JFrame 实现用户注册

效果
在这里插入图片描述

Register.java

public class Register extends JFrame {

    public Register(){
        // 设置标题
        this.setTitle("用户注册");
        // 窗口大小
        this.setSize(488, 430);
        // 压过其他软件,放置最上方
        this.setAlwaysOnTop(true);
        // 设置居中打开
        this.setLocationRelativeTo(null);
        // 设置关闭游戏(这里的关闭指Java虚拟机运行也关闭,不是视觉上的关闭)
        this.setDefaultCloseOperation(3);
        // 布局
        this.setLayout(new GridLayout(8 ,1));

        // 用户名
        JPanel jPanel1 = new JPanel();
        JLabel jLabel1 = new JLabel("用户名");
        jPanel1.add(jLabel1);
        JTextField jTextField1 = new JTextField(15);
        jPanel1.add(jTextField1);
        this.add(jPanel1);

        // 密码
        JPanel jPanel2 = new JPanel();
        JLabel jLabel2 = new JLabel("密码");
        jPanel2.add(jLabel2);
        JPasswordField jPasswordField2 = new JPasswordField(15);
        jPanel2.add(jPasswordField2);
        this.add(jPanel2);

        // 确认密码
        JPanel jPanel3 = new JPanel();
        JLabel jLabel3 = new JLabel("确认密码");
        jPanel3.add(jLabel3);
        JPasswordField jPasswordField3 = new JPasswordField(15);
        jPanel3.add(jPasswordField3);
        this.add(jPanel3);

        // 性别
        JPanel jPanel4 = new JPanel();
        JLabel jLabel4 = new JLabel("性别");
        jPanel4.add(jLabel4);
        JRadioButton jRadioButton1 = new JRadioButton("男");
        jPanel4.add(jRadioButton1);
        JRadioButton jRadioButton2 = new JRadioButton("女");
        jPanel4.add(jRadioButton2);
        this.add(jPanel4);

        // 爱好
        JPanel jPanel5 = new JPanel();
        JLabel jLabel5 = new JLabel("爱好");
        jPanel5.add(jLabel5);
        JCheckBox jCheckBox1 = new JCheckBox("阅读");
        jPanel5.add(jCheckBox1);
        JCheckBox jCheckBox2 = new JCheckBox("上网");
        jPanel5.add(jCheckBox2);
        JCheckBox jCheckBox3 = new JCheckBox("游泳");
        jPanel5.add(jCheckBox3);
        JCheckBox jCheckBox4 = new JCheckBox("旅游");
        jPanel5.add(jCheckBox4);
        this.add(jPanel5);

        // 地址
        JPanel jPanel6 = new JPanel();
        JLabel jLabel6 = new JLabel("地址");
        jPanel6.add(jLabel6);
        JTextArea jTextArea = new JTextArea(3, 20);
        jPanel6.add(jTextArea);
        this.add(jPanel6);

        // 学历
        JPanel jPanel7 = new JPanel();
        JLabel jLabel7 = new JLabel("学历");
        jPanel7.add(jLabel7);
        String[] degree = {"A","B","C","D"};
        JComboBox<String> jComboBox = new JComboBox<>(degree);
        jPanel7.add(jComboBox);
        this.add(jPanel7);

        JPanel jPanel8 = new JPanel();
        JButton jButton1 = new JButton("注册");
        jPanel8.add(jButton1);
        JButton jButton2 = new JButton("取消");
        jPanel8.add(jButton2);
        this.add(jPanel8);

        // 设置窗口是否显示,默认为false
        this.setVisible(true);
    }


    public static void main(String[] args) {
        new Register();
    }

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值