博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
等价类划分例子中的些许添加
阅读量:4837 次
发布时间:2019-06-11

本文共 3703 字,大约阅读时间需要 12 分钟。

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

 

 

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();

    }

}

 结果如下:

 

 

其他不再重复。

 

 

转载于:https://www.cnblogs.com/wangdongT-T/p/4376433.html

你可能感兴趣的文章
敏捷软件开发模型Scrum通俗讲义
查看>>
VS2010连接SQLite数据库
查看>>
8.2 tp5跨控制器调用,方法调用
查看>>
记录git rebase用法
查看>>
mobile体验效果:增加点击后反馈
查看>>
巴塞尔表展视频观后感
查看>>
java中时间比较
查看>>
30分钟学会如何使用Apache Shiro
查看>>
业务图形系统框架设计--一个为了减少图形引擎替换工作量的设计
查看>>
Python Flask
查看>>
编程思想之递归
查看>>
介绍MFC框架中涉及到的设计模式(二)
查看>>
asp.net部署时加密config文件
查看>>
[摘抄]Memory Allocation/Deallocation Bottleneck?(内存分配/释放瓶颈)
查看>>
hdu1024 最大m子串和
查看>>
React Native技术做的一个项目“微笑阅读”
查看>>
까페24 호스팅 php 에러메세지 출력
查看>>
想开个网店的。。学习一下vancl的分析
查看>>
如何用BlazeDS更改图片
查看>>
HTML 表单
查看>>