load异常错误导致程序无法运行

bz4sfanl  于 2021-07-06  发布在  Java
关注(0)|答案(1)|浏览(357)

我正在处理一个应用程序,当我尝试运行它时,我不断得到以下错误:

  1. Exception in Application start method
  2. java.lang.reflect.InvocationTargetException
  3. Caused by: java.lang.RuntimeException: Exception in Application start method
  4. at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
  5. at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$1(LauncherImpl.java:182)
  6. at java.lang.Thread.run(Thread.java:748)
  7. Caused by: javafx.fxml.LoadException:
  8. /Users/x/IdeaProjects/management%20system/out/production/management%20system/login.fxml:11

以下是应用程序启动方法:

  1. public void start (Stage stage) throws Exception{
  2. Parent root = (Parent) FXMLLoader.load(getClass().getResource("login.fxml"));
  3. Scene scene = new Scene(root);
  4. stage.setScene(scene);
  5. stage.setTitle("Employee management system");
  6. stage.show(); //showing the window
  7. }

下面是fxml文件:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <?import javafx.scene.control.Button?>
  3. <?import javafx.scene.control.ComboBox?>
  4. <?import javafx.scene.control.Label?>
  5. <?import javafx.scene.control.PasswordField?>
  6. <?import javafx.scene.control.TextField?>
  7. <?import javafx.scene.layout.AnchorPane?>
  8. *line 11 <AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controller">
  9. <children>
  10. <Label layoutX="30.0" layoutY="14.0" text="Database status " />
  11. <TextField fx:id="username" layoutX="30.0" layoutY="125.0" />
  12. <Label layoutX="30.0" layoutY="99.0" text="Username" />
  13. <Label layoutX="30.0" layoutY="174.0" text="Password" />
  14. <PasswordField fx:id="password" layoutX="30.0" layoutY="200.0" />
  15. <ComboBox fx:id="combobox" layoutX="30.0" layoutY="268.0" prefWidth="150.0" promptText="Manager/Employee" />
  16. <Button fx:id="Login" layoutX="61.0" layoutY="338.0" mnemonicParsing="false" text="Login" />
  17. <Label fx:id="dbstatus" layoutX="186.0" layoutY="14.0" text="Label" />
  18. </children>
  19. </AnchorPane>

我假设这个错误与我的fxml文件有关,但是在查看文件之后,我找不到可能的原因,我想知道错误的原因是什么?

u3r8eeie

u3r8eeie1#

我想出来了,我得把主播的fx:控制器去掉

相关问题