About 3 EditBox tests and the corresponding Java programs

Source: Internet
Author: User
Tags gettext string back

Related issues:

There are 3 editbox, each allowing input of 1~6 characters or numbers, press ENTER to end

Focus Point:

Enter the length of the character, enter the type of character

Equivalence class Partitioning:

Number Valid or invalid Equivalence class content
1 Effective Length of 1-6
2 Effective Content is English characters or numbers
3 Effective 3 EditBox are correct.
4 Invalid Length of 0 or greater than 6
5 Invalid The content is not all English characters and numbers
6 Invalid 3 EditBox Not all right

Test Case:

Input 1 Input 2 Input 3 overriding equivalence classes Predictive output
123 Abc As1acx 123 Ok
123 Abc 426 False
123 Abc As1acx 156 False
1234567 Abc. As1acx 456 False

Test results:

Code:

1 Importjavafx.application.Application;2 Importjavafx.event.ActionEvent;3 ImportJavafx.event.EventHandler;4 ImportJavafx.scene.*;5 ImportJavafx.scene.control.Button;6 ImportJavafx.scene.control.TextField;7 ImportJavafx.scene.layout.AnchorPane;8 ImportJavafx.scene.layout.StackPane;9 ImportJavafx.scene.text.Text;Ten ImportJavafx.stage.Stage; One  A  classKuangextendsanchorpane{ -Text Text =NewText ("Name:"); -TextField textfield=NewTextField (); the      Doublehight = 0; -Kuang (Doublehight,anchorpane pane) { -          This. GetChildren (). AddAll (Text,textfield); -          This. hight =hight; +Anchorpane.settopanchor ( This, hight); -Anchorpane.setleftanchor ( This, 50.0); +Pane.getchildren (). Add ( This); A     } at      Public BooleanCheck () { -         intLength = This. Textfield.gettext (). Length (); -         if(Length > 6 | | length < 1) -             return false; -          for(CharA: This. Textfield.gettext (). ToCharArray ()) { -             if(! Character.isalphabetic (a) &&!Character.isdigit (a)) in                 return false; -         } to         return true; +     } - } the  Public classMyTestextendsApplication { *  $     /**Panax Notoginseng      * @paramargs -      */ the      Public Static voidMain (string[] args) { +         //TODO auto-generated Method Stub A mytest.launch (args); the  +     } -  $ @Override $      Public voidStart (Stage stage)throwsException { -         //TODO auto-generated Method Stub -Stage.settitle ("MyTest"); theAnchorpane root =NewAnchorpane (); -         FinalKuang kuang1=NewKuang (50, root);Wuyi         FinalKuang kuang2=NewKuang (100, root); the         FinalKuang Kuang3 =NewKuang (150, root); -Button but =NewButton ("Enter"); WuBut.setonaction (NewEventhandler<actionevent>(){ -              Public voidhandle (ActionEvent event) { AboutString back = "false"; $                 if(Kuang1.check () &&kuang2.check () &Kuang3.check ()) { -back = "OK"; -                 } - System.out.println (back); A                 } +         }); theAnchorpane.settopanchor (But, 200.0); -Anchorpane.setleftanchor (But, 100.0); $ Root.getchildren (). Add (But); theStage.setscene (NewScene (root,250,250)); the stage.show (); the     } the  -}

About 3 EditBox tests and the corresponding Java programs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.