Bonjour;
Dans le code suivant je voudrais controler mes entrées;j'ai fait le code suivant mais je ne peux entrer qu'une seule lettre;comment entrer plusieurs lettres a la suite?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package textfieldplus;
 
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
 
 
public class Textfieldplus extends Application {
    TextField t1;
    @Override
    public void start(Stage primaryStage) {
        Button btn = new Button();
        btn.setText("Say 'Hello World'");
        t1=new TextField();
        t1.setLayoutX(50);
        t1.setLayoutY(50);
        t1.setPrefWidth(50);
        btn.setOnAction(new EventHandler<ActionEvent>() {
 
            @Override
            public void handle(ActionEvent event) {
                System.out.println("Hello World!");
            }
        });
 
        AnchorPane root = new AnchorPane();
        root.getChildren().addAll(btn,t1);
 
        Scene scene = new Scene(root, 300, 250);
        scene.setOnKeyReleased((KeyEvent t)->{
        entertxt(t);
    });
        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        primaryStage.show();
    }
 
public void entertxt(KeyEvent k){
    t1.setText(k.getText());
 
}
 
    /**
     * The main() method is ignored in correctly deployed JavaFX application.
     * main() serves only as fallback in case the application can not be
     * launched through deployment artifacts, e.g., in IDEs with limited FX
     * support. NetBeans ignores main().
     *
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
 
}