I have the problem that when I call my method loginerroroutput
in the Java controller from another class in another package. I cannot change the label (fx:id="loginerrormessage"
) with setText
. I get a NullPointerException
as error. The method is called, but the label is not found. When I call this method (loginerroroutput
) through a method of my controller, it works.
Controller Code
package gui;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import java.net.URL;
import java.util.ResourceBundle;
public class LoginController {
private ResourceBundle resources;
private URL location;
@FXML
public Label Loginerrormessage;
// Aufruf vom Eventbus für alle Fehler für das Login-> Fehlerausgabe als String wird angezeigt
public void loginerroroutput(String string){
System.out.println(string); //Console output string
Loginerrormessage.setText(string); // Console output null
}
public void initialize() {
}
}
I'm pretty sure it's the initialize()
method because I think that method is responsible for the post-processing processes.
Thank you for your tips and suggestions.