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

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

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

Exception in Application start method
java.lang.reflect.InvocationTargetException

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

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

public void start (Stage stage) throws Exception{
    Parent root = (Parent) FXMLLoader.load(getClass().getResource("login.fxml"));

    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("Employee management system");
    stage.show(); //showing the window
}

下面是fxml文件:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
   *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">
   <children>
      <Label layoutX="30.0" layoutY="14.0" text="Database status " />
      <TextField fx:id="username" layoutX="30.0" layoutY="125.0" />
      <Label layoutX="30.0" layoutY="99.0" text="Username" />
      <Label layoutX="30.0" layoutY="174.0" text="Password" />
      <PasswordField fx:id="password" layoutX="30.0" layoutY="200.0" />
      <ComboBox fx:id="combobox" layoutX="30.0" layoutY="268.0" prefWidth="150.0" promptText="Manager/Employee" />
      <Button fx:id="Login" layoutX="61.0" layoutY="338.0" mnemonicParsing="false" text="Login" />
      <Label fx:id="dbstatus" layoutX="186.0" layoutY="14.0" text="Label" />
   </children>
</AnchorPane>

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

u3r8eeie

u3r8eeie1#

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

相关问题