zoukankan      html  css  js  c++  java
  • 验证码窗口

    package 大大大;
    import java.util.Random;
    import javax.swing.JOptionPane;
    import javax.swing.*;
    public class kuang {
        public static void main(String[] args) {
            JTextField name=new JTextField(5);
            JTextField x=new JTextField(5);
            JTextField key=new JTextField(5);
            JPanel myPanel=new JPanel();
            StringBuffer buffer = new StringBuffer("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
            StringBuffer sb = new StringBuffer();
            Random r = new Random();
            JTextField yanzhengma=new JTextField(5);
            int range = buffer.length();
            for (int i = 0; i <4 ; i++) {
                sb.append(buffer.charAt(r.nextInt(range)));
            }
            myPanel.add(new JLabel("账号:"));
            myPanel.add(name);
            myPanel.add(Box.createHorizontalStrut(15));//a spacer
            myPanel.add(new JLabel("密码:"));
            myPanel.add(key);
            myPanel.add(Box.createHorizontalStrut(15));//a spacer
            
            myPanel.add(new JLabel("请输入验证码:"));
            myPanel.add(yanzhengma);
            myPanel.add(Box.createHorizontalStrut(15));//a spacer
            myPanel.add(new JLabel("验证码为:"+sb));
             JOptionPane.showConfirmDialog(null, myPanel,"Please Enter name and key ", JOptionPane.OK_CANCEL_OPTION);
    
                if (yanzhengma.getText().toString().equals(sb.toString())) {
                    JOptionPane.showMessageDialog(null, "验证码成功", "验证", JOptionPane.INFORMATION_MESSAGE);
                } else {
                    JOptionPane.showMessageDialog(null, "验证码错误", "验证", JOptionPane.INFORMATION_MESSAGE);
            }
        }
    }

     

  • 相关阅读:
    as3 return语句中的运算符
    AIR custom ApplicationUpdaterUI
    Flash Builder 无法连接到应用程序以访存概要分析数据
    Android的所有权限说明
    Tomcat数据源配置
    hibernate 延迟加载(懒加载)
    Android SQLite数据库操作
    Android下载文本文件和mp3文件
    JPA注解
    Android Intent传值且实现窗体跳转
  • 原文地址:https://www.cnblogs.com/feng747/p/13771580.html
Copyright © 2011-2022 走看看