bonjour tout le monde voila, suis un peut debutant en java FXML et j'ai un petit soucis .
je veux recuperer la valeur d'un text saisie dans un textfields pour l'afficher a l'ecran sauf que a l'execution j'obtient cette erreur java.lang.NullPointerException
voila mon code FXML:
et mon code JAVA :
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 <GridPane id="gridconnexion" hgap="30" vgap="10" alignment="BASELINE_CENTER" > <padding> <Insets right="50" top="70" > </Insets> </padding> <Text id="MSGConnexion" text="Connexion" GridPane.columnIndex="0" GridPane.rowIndex="0" /> <Label id="userSpeudo" text="Pseudo" GridPane.columnIndex="0" GridPane.rowIndex="1" /> <TextField fx:id="InpuPseudo" GridPane.columnIndex="1" GridPane.rowIndex="1" promptText="nom d'utlisateur" prefWidth="250" /> <Label id="userpwd" text="Mot de passe" GridPane.columnIndex="0" GridPane.rowIndex="2" /> <PasswordField fx:id="InputPwd" GridPane.columnIndex="1" GridPane.rowIndex="2" promptText="mot de passe" prefWidth="250" /> <HBox spacing="20" GridPane.columnIndex="1" GridPane.rowIndex="3" alignment="BOTTOM_RIGHT" > <Button fx:id="cancel" text="Annuler" prefWidth="100" /> <Button fx:id="submit" text="Connexion" prefWidth="100" onAction="#submitPressed" /> </HBox> <HBox spacing="20" GridPane.columnIndex="1" GridPane.rowIndex="5" > <Text fx:id="actiontarget" /> </HBox> </GridPane>
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 @FXML private Text actiontarget ; @FXML private TextField InputPseudo ; @FXML private PasswordField InputPwd ; public PasswordField getPwd() { return this.InputPwd ; } public void setPwd(PasswordField InputPwd) { this.InputPwd = InputPwd ; } public TextField getPseudo() { return this.InputPseudo ; } public void setPseudo (TextField InputPseudo) { this.InputPseudo = InputPseudo ; } public void submitPressed (ActionEvent event) { actiontarget.setText(InputPseudo.getText()); } @Override public void initialize(URL location, ResourceBundle resources) { }
Partager