A java.lang.NullPointerException error occurs when trying to set text in a label and read it from a label.
package application; import java.net.URL; import java.util.ResourceBundle; import javafx.fxml.FXML; import javafx.scene.layout.AnchorPane; import javafx.scene.control.Button; import javafx.scene.control.Label; public class DialogConroller { @FXML private static Button btn_savefile; @FXML private static Label label; @FXML private ResourceBundle resources; @FXML private URL location; @FXML private AnchorPane paneAnch; @FXML void initialize() { paneAnch.setMaxSize(100, 300); System.out.println(label.getText().toString()); // Platform.runLater((() -> label.setText(""))); } } There were also attempts to shove in a separate stream, but it led to nothing.
FXMLLoader load = new FXMLLoader(); load.setLocation(getClass().getResource("/application/dialog.fxml")); try { load.load(); } catch (IOException e) { e.printStackTrace(); } Stage stage = new Stage(); Parent root = load.getRoot(); Scene scene = new Scene(root, 300,100); stage.setScene(scene); stage.setResizable(false); stage.showAndWait();The static variable, since created automatically via SceneBuilder - Bagul