So i've been playing around with javaFx and FXML and i keep running into a problem where i get errors when using a conditional statement with something like a .getText()
method and trying to reference an FXML variable and its Items/children from within the bounds of this.
Take for example:
Public Void checkTextField(TextField txt, AnchorPane pane){
//#1
system.out.println(pane.getItems());
if(txt.getText() != null && !txt.getText().isEmpty())
//#2
system.out.println(pane.getItems());
}
In this example #1 always works for me and will print out a list of what i've got in my pane (Or any container for that matter), whereas with #2 i always seem to get a NullPointerException
and a InvocationTargetException
if anyone knows why this could be, it would be great to find out what i'm doing wrong here or what i could add to make it work
cheers
Aucun commentaire:
Enregistrer un commentaire