?????????????????????????????Щ??????????????????????Щ????ɡ?
????????????
????????1??6?????????????????OK????
??????Ч?????: ????:1??6?????:a-z??A-Z??0-9
??????Ч??????????0??7????????????????????????????????????????
????????????????????????в???????????£?
1 import java.awt.event.MouseAdapter;
2
3 import javafx.application.Application;
4 import javafx.event.ActionEvent;
5 import javafx.event.EventHandler;
6 import javafx.scene.Scene;
7 import javafx.scene.control.Button;
8 import javafx.scene.control.TextArea;
9 import javafx.scene.input.MouseEvent;
10 import javafx.scene.layout.AnchorPane;
11 import javafx.stage.Stage;
12
13
14 public class testview extends Application{
15     public TextArea text[]=new TextArea[3];
16     /**
17      * @param args
18      */
19     public static void main(String[] args) {
20         // TODO Auto-generated method stub
21         Application.launch(args);
22     }
23     public void start(Stage stage) throws Exception{
24         stage.setTitle("Testing");
25         AnchorPane root=new AnchorPane();
26         Scene scene=new Scene(root??300??300);
27
28         for(int i=0;i<3;i++){
29             text[i]=new TextArea();
30             text[i].setLayoutX(20);
31             text[i].setLayoutY(i*30+100);
32             text[i].setMaxHeight(30);
33             text[i].setPrefColumnCount(10);
34             root.getChildren().add(text[i]);
35         }
36         Button btn=new Button("OK");
37         btn.setLayoutX(100);
38         btn.setLayoutY(200);
39         root.getChildren().add(btn);
40         btn.setOnAction(new EventHandler<ActionEvent>(){
41             public void handle(ActionEvent e){
42                 String str = new String();
43                 boolean result=true;
44                 for(int i=0;i<3;i++){
45                     result=true;
46                     str= text[i].getText();
47                     if(str.length()>0 && str.length()<7){
48                         for(int j=0;j<str.length();j++){
49                             if(!Character.isDigit((str.charAt(j)))&&!Character.isLetter(str.charAt(j))) {
50                                 result=false;
51                                 break;
52                             }
53                         }
54                     }
55                     else result=false;
56                 System.out.println(result);
57                 }
58
59             }
60         });
61         stage.setScene(scene);
62         stage.show();
63     }
64 }