package daima;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class test1 implements ActionListener {
    JFrame   f1,f2;
    JPanel   p1,p2;
    JButton  b;
    JLabel   l1,l2,l3,l4;
    JTextField t1,t2,t3;
    private boolean Flase;
    public test1() {
        f1=new JFrame("qq注册");
        p1=new JPanel();
        l1=new JLabel("手机号码:");
        t1=new JTextField(15);
        l2=new JLabel("设置密码:");
        t2=new JTextField(15);
        l4=new JLabel("确认密码:");
        t3=new JTextField(15);
        b=new JButton("确定");
        b.addActionListener(this);
        p1.add(l1);
        p1.add(t1);
        p1.add(l2);
        p1.add(t2);
        p1.add(l4);
        p1.add(t3);
        p1.add(b);
        f1.add(p1);                                                                                                
        f1.setSize(250,200);
        f1.setLocation(400, 100);
        f1.setVisible(true);
        p1.setBackground(Color.pink);
        f2=new JFrame();
        p2=new JPanel();
        l3=new JLabel();
        p2.add(l3);
        f2.add(p2);
        f2.setSize(100,100);
        f2.setLocation(410, 110);
        p2.setBackground(Color.pink);
        f2.setVisible(Flase);
        
        }
        public static void main(String[]args) {
            new test1();
        }
        @Override
        public void actionPerformed(ActionEvent e) {
            String a,b,c;
            int n,m,k=0;
            a=t1.getText();
            b=t2.getText();
            c=t3.getText();
            n=a.length();
            m=b.length();
            for(int j=m-1;j>=0;j--) {
                int  chr=b.charAt(j);
                if(chr>=97&&chr<=122||chr>=65&&chr<=90||chr>=48&&chr<=57){
                }else k++;
            }
            if(n==11&&k==0&&b.equals(c)){    
                l3.setText("创建成功!");
                f2.setVisible(true);    
            }else {
                l3.setText("创建失败!");
                f2.setVisible(true);    
            }    
        }
    }
        
    

 

 

posted on 2019-05-12 23:12  卢思林  阅读(120)  评论(0编辑  收藏  举报