-1
I’m trying to change a label lbl1
by the FXML controller builder method.
public class TestController extends Application {
@FXML
private Label lbl1;
public TestController()
{
lbl1.setText("Teste");
}
@Override
public void start(Stage primaryStage)
{
}
public static void main(String[] args)
{
launch(args);
}
}
When trying to change the label text, the following error occurs:
javafx.fxml.Loadexception: /D:/Users/Gabriel%20August/eclipse-Workspace/Dialog/bin/FXML/Test.fxml:10
at javafx.fxml.Fxmlloader.constructLoadException(Fxmlloader.java:2601) at javafx.fxml.Fxmlloader.loadImpl(Fxmlloader.java:2579) at javafx.fxml.Fxmlloader.loadImpl(Fxmlloader.java:2441) at javafx.fxml.Fxmlloader.load(Fxmlloader.java:2409) at application.test.start(Login.java:47) at com.sun.javafx.application.Launcherimpl.lambda$launchApplication1$166(Launcherimpl.java:863) at com.sun.javafx.application.Platformimpl.lambda$runAndWait$179(Platformimpl.java:326) at com.sun.javafx.application.Platformimpl.lambda$null$177(Platformimpl.java:295) at java.security.Accesscontroller.doPrivileged(Native Method) at com.sun.javafx.application.Platformimpl.lambda$runLater$178(Platformimpl.java:294) at com.sun.Glass.ui.Invokelaterdispatcher$Future.run(Invokelaterdispatcher.java:95) at com.sun.Glass.ui.win.WinApplication. _runLoop(Native Method) at com.sun.Glass.ui.win.WinApplication.lambda$null$152(Winapplication.java:177) at java.lang.Thread.run(Unknown Source) Caused by:java.lang.Nullpointerexception at application.TestController.(Testcontroller.java:198) at sun.reflect.Nativeconstructoraccessorimpl.newInstance0(Native Method) at sun.reflect.Nativeconstructoraccessorimpl.newInstance(Unknown Source) at sun.reflect.Delegatingconstructoraccessorimpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at sun.reflect.Misc.ReflectUtil.newInstance(Unknown Source) at javafx.fxml.Fxmlloader$Valueelement.processAttribute(Fxmlloader.java:927) at javafx.fxml.Fxmlloader$Instancedeclarationelement.processAttribute(Fxmlloader.java:971) at javafx.fxml.Fxmlloader$Element.processStartElement(Fxmlloader.java:220) at javafx.fxml.Fxmlloader$Valueelement.processStartElement(Fxmlloader.java:744) javafx.fxml.Fxmlloader.processStartElement(Fxmlloader.java:2707) javafx.fxml.Fxmlloader.loadImpl(Fxmlloader.java:2527) ... 12 more
The controller is properly configured to FXML. The error occurs when trying to change the label text contained in FXML.