Javafx error exception in Application start method no controller specified

前端 未结 3 943
一个人的身影
一个人的身影 2020-11-29 12:41

When I run the following code in intellij with java 8 I get an error. Please Help. The fxml is generated using the scene builder, I think the button Dagrooster isn\'t linked

相关标签:
3条回答
  • 2020-11-29 12:45

    The error says it, the FXML is missing the fx:controller declaration. Add the controller declaration to BorderPane declaration as shown :

    ...
    <BorderPane maxHeight="1.7976931348623157E308" 
          maxWidth="1.7976931348623157E308" prefHeight="400.0" 
           prefWidth="600.0" xmlns="http://javafx.com/javafx/8"
             xmlns:fx="http://javafx.com/fxml/1" 
                              fx:controller="Weert.Controller">
    ...
    

    To know how to set controller class via SceneBuilder, you can have a look at this question.

    0 讨论(0)
  • 2020-11-29 12:54

    As the error implies, problem is in "fxml", in which it is referring to class which do not exist. To solve this search an attribute called "fx:controller" and assign it qualified class name . For an instance "fx:controller="packagename.className".

    0 讨论(0)
  • 2020-11-29 13:08

    It is true you havent told the fxml file where the controller class is...

    this ...

    <BorderPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
    

    As this...

    <BorderPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Weert.Controller">
    

    Or even this...

    <BorderPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controller">
    

    .. then put both files in the same folder

    0 讨论(0)
提交回复
热议问题