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中事件
    pku 1836 Alignment
    pku 3086 Triangular Sums
    [转]asp格式化日期
    用数组作checkboxlist数据源
    (转)Membership、MembershipUser和Roles类 详解
    asp中判断 checkbox 是否选中
    使用 AddRange 方法将多个 ListItem 对象添加到集合
    My97DatePicker,一个兼容所有浏览器的日历选择脚本(相当经典)
    .Net下批量删除数据的存储过程问题(用动态SQL )
  • 原文地址:https://www.cnblogs.com/wangdongT-T/p/4376433.html
Copyright © 2011-2022 走看看