zoukankan      html  css  js  c++  java
  • 等价类划分例子中的些许添加

    之前的等价类划分的些许添加。例如基本要求的用户名,密码,验证码等输入检验。增加三组分别的检验。代码如下:

     

    public void start(Stage stage)throws Exception {

       

            stage.setTitle("TEST");

            AnchorPane root = new AnchorPane();

            Scene scene = new Scene(root, 500, 500);

            scene.setFill(Color.WHITE);

           

            Text usename= new Text("用户名:");

            usename.setFont(Font.font ("Serif", 28));

            AnchorPane.setTopAnchor(usename, 100.0);

            AnchorPane.setLeftAnchor(usename, 50.0);

           

            Text password = new Text("密码:");

            password.setFont(Font.font ("Serif", 28));

            AnchorPane.setTopAnchor(password, 200.0);

            AnchorPane.setLeftAnchor(password, 50.0);

           

            Text test= new Text("验证码:");

            test.setFont(Font.font ("Serif", 28));

            AnchorPane.setTopAnchor(test, 300.0);

            AnchorPane.setLeftAnchor(test, 50.0);

           

            Text tips= new Text("验证1:");

            tips.setFont(Font.font ("Serif", 28));

            AnchorPane.setTopAnchor(tips, 150.0);

            AnchorPane.setLeftAnchor(tips, 50.0);

           

            Text tips2= new Text("验证2:");

            tips2.setFont(Font.font ("Serif", 28));

            AnchorPane.setTopAnchor(tips2, 250.0);

            AnchorPane.setLeftAnchor(tips2, 50.0);

           

            Text tips3= new Text("验证3:");

            tips3.setFont(Font.font ("Serif", 28));

            AnchorPane.setTopAnchor(tips3, 350.0);

            AnchorPane.setLeftAnchor(tips3, 50.0);

           

            Text tips4= new Text("总验证:");

            tips4.setFont(Font.font ("Serif", 28));

            AnchorPane.setTopAnchor(tips4, 400.0);

            AnchorPane.setLeftAnchor(tips4, 50.0);

           

            final TextField textblock=new TextField();

            AnchorPane.setTopAnchor(textblock, 105.0);

            AnchorPane.setLeftAnchor(textblock, 200.0);

           

            final TextField textblock2=new TextField();

            AnchorPane.setTopAnchor(textblock2, 155.0);

            AnchorPane.setLeftAnchor(textblock2, 200.0);

           

            final TextField textblock3=new TextField();

            AnchorPane.setTopAnchor(textblock3, 205.0);

            AnchorPane.setLeftAnchor(textblock3, 200.0);

           

            final TextField textblock4=new TextField();

            AnchorPane.setTopAnchor(textblock4, 255.0);

            AnchorPane.setLeftAnchor(textblock4, 200.0);

           

            final TextField textblock5=new TextField();

            AnchorPane.setTopAnchor(textblock5, 305.0);

            AnchorPane.setLeftAnchor(textblock5, 200.0);

           

            final TextField textblock6=new TextField();

            AnchorPane.setTopAnchor(textblock6, 355.0);

            AnchorPane.setLeftAnchor(textblock6, 200.0);

           

            final TextField textblock7=new TextField();

            AnchorPane.setTopAnchor(textblock7, 405.0);

            AnchorPane.setLeftAnchor(textblock7, 200.0);

           

           

            Button button = new Button("检验");

            AnchorPane.setTopAnchor(button, 405.0);

            AnchorPane.setRightAnchor(button, 50.0);

           

            button.setOnAction( new EventHandler<ActionEvent>( ) {

                public void handle(ActionEvent actEvt) {       

                    final String input1;

                    final String input2;

                    final String input3;

                    boolean ziz = true;

                    input1 = textblock.getText();

                    input2 = textblock3.getText();

                    input3 = textblock5.getText();

                    //1

                    if(input1.length() > 6|| input1.length() < 1){

                      ziz = false;

                      textblock2.setText("er1:长度应为1-6");

                    }

                    else if(!isRegularRptCode(input1,"[a-z,A-Z,0-9]*")){

                      ziz = false;

                      textblock2.setText("er2: 字符应为a-z,A-Z,0-9");

                    }

                    else{

                      textblock2.setText("OK!!");

                    }

                    //2

                    if(input2.length() > 6|| input2.length() < 1){

                      ziz = false;

                      textblock4.setText("er1:长度应为1-6");

                    }

                    else if(!isRegularRptCode(input2,"[a-z,A-Z,0-9]*")){

                      ziz = false;

                      textblock4.setText("er2: 字符应为a-z,A-Z,0-9");

                    }

                    else{

                      textblock4.setText("OK!!");

                    }

                    //3

                    if(input3.length() > 6|| input3.length() < 1){

                      ziz = false;

                      textblock6.setText("er1:长度应为1-6");

                    }

                    else if(!isRegularRptCode(input3,"[a-z,A-Z,0-9]*")){

                      ziz = false;

                      textblock6.setText("er2: 字符应为a-z,A-Z,0-9");

                    }

                    else{

                      textblock6.setText("OK!!");

                    }

                   

                    if(ziz == true){

                      textblock7.setText("OK!!!");

                    }

                    else{

                      textblock7.setText("输入有误请重新输入。");

                    }

                }

            } );

            root.getChildren().addAll(usename,tips,tips2,tips3,tips4,password,button,test,

                 textblock,textblock2,textblock3,textblock4,textblock5,textblock6,textblock7);

            stage.setScene(scene);

            stage.show();

        }

    }

     结果如下:

    其他不再重复。

  • 相关阅读:
    JavaScript实现类的private、protected、public、static以及继承
    OSS网页上传和断点续传(STSToken篇)
    OSS网页上传和断点续传(OSS配置篇)
    Linq sum()时遇到NULL
    SQLSERVER事务日志已满 the transaction log for database 'xx' is full
    笔记本高分辨软件兼容问题,字体太小或模糊
    H5上传图片之canvas
    An error occurred while updating the entries. See the inner exception for details.
    无限级结构SQL查询所有的下级和所有的上级
    SQLserver 进程被死锁问题解决
  • 原文地址:https://www.cnblogs.com/wangdongT-T/p/4376433.html
Copyright © 2011-2022 走看看