Java如何添加验证码_java如何加数字验证码

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

package x;

import javax.swing.*;

import java.awt.*;

import java.util.Random;

public class Register {

public static void main(String[] args) {

new Infor();

}

}

class Infor extends JFrame{

private Container contentPane;

private JPanel pnl,pn2;

private JLabel lblUserId,lblRegUser,lblLoginPassword,lblForgetPassword,lbl;

private JTextField txtUserId;

private JButton btn1,btn2 ;

private Checkbox cheBox1,cheBox2;

private ImageIcon Icon;

private JPasswordField txtLoginPassword;

public Infor () {

super("铁路订票系统");

this.setSize(560,500);

setDefaultCloseOperation(EXIT_ON_CLOSE);

setLocationRelativeTo(null);

initComponents();

setVisible(true);

//addListener();

}

public void initComponents() {

contentPane = this.getContentPane();

pn2 = new JPanel();

pn2.setLayout(null);

// pn2.setBackground(Color.CYAN);

pnl = new JPanel();

pnl.setPreferredSize(new Dimension(550,280));

//pnl.setBackground(Color.blue);

Icon = new ImageIcon("image/t.jpg");

lbl = new JLabel(Icon);

pnl.add(lbl);

Font font = new Font("楷体",Font.BOLD,15);

lblUserId = new JLabel();

lblUserId.setText("登录账号:");

lblUserId.setBounds(100,20,80,30);

lblUserId.setFont(font);

txtUserId = new JTextField();

txtUserId.setBounds(190,25,120,20);

lblRegUser = new JLabel();

lblRegUser.setText("注册用户");

lblRegUser.setBounds(340,20,120,30);

lblLoginPassword = new JLabel();

lblLoginPassword.setText("登录密码:");

lblLoginPassword.setBounds(100,45,120,30);

lblLoginPassword.setFont(font);

txtLoginPassword = new JPasswordField();

txtLoginPassword.setBounds(190,50,120,20);

txtLoginPassword.setEchoChar(***);

lblForgetPassword = new JLabel();

lblForgetPassword.setText("忘记密码");

lblForgetPassword.setBounds(340,45,120,30);

cheBox1 = new Checkbox("记住密码");

cheBox1.setBounds(170,65,70,30);

cheBox2 = new Checkbox("自动登录");

cheBox2.setBounds(260,65,70,30);

btn1 = new JButton("登录");

btn1.setBounds(180,140,60,30);

btn2 = new JButton("取消");

btn2.setBounds(260,140,60,30);

pn2.add(txtUserId);

pn2.add(lblUserId);

pn2.add(lblRegUser);

pn2.add(txtLoginPassword);

pn2.add(lblLoginPassword);

pn2.add(lblForgetPassword);

pn2.add(cheBox1);

pn2.add(cheBox1);

pn2.add(cheBox2);

pn2.add(btn1);

pn2.add(btn2);

contentPane.add(pn2);

contentPane.add(pnl,BorderLayout.NORTH);

}

}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值