0

I have a function:

    public static void printOnLable(String str){
    try {
        labelAkcja.textProperty().setValue(str);
    } catch(Throwable e) {
        System.err.println(e);
        System.err.println("Cause = " + e.getCause());
    }
}

but when i want to call it

Controller.printOnLable("server started");

I get always an error

enter image description here

Katherine
  • 1
  • 3
  • Either `labelAkcja` or `textProperty()` are null. Make sure they aren't. – Amongalen May 20 '20 at 10:54
  • 1
    Does this answer your question? [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – Amongalen May 20 '20 at 10:54
  • @Amongalen just a note: the property is never null, its value might, though not a problem here :) – kleopatra May 20 '20 at 10:56
  • ye, this one is my – Katherine May 20 '20 at 10:57
  • @kleopatra We can't really be sure what `labelAkcja` is, it could be of some class that OP created :) – Amongalen May 20 '20 at 11:02
  • @Amongalen whatever it is, if it allows a property to be null its API is severely broken :) – kleopatra May 20 '20 at 11:03
  • 1
    Reasonably good chance (making some guesses about the different roles of members in the code snippet) https://stackoverflow.com/questions/23105433/javafx-8-compatibility-issues-fxml-static-fields is also relevant. – James_D May 20 '20 at 11:45

0 Answers0