Java FXML文件中的加载异常错误导致程序无法运行
我正在处理一个应用程序,当我尝试运行它时,我不断收到以下错误:Java FXML文件中的加载异常错误导致程序无法运行,java,exception,load,driver,fxml,Java,Exception,Load,Driver,Fxml,我正在处理一个应用程序,当我尝试运行它时,我不断收到以下错误: 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.launchAp
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>
*第11行
我假设错误与我的fxml文件有关,但是在查看该文件后,我找不到可能的原因,并且想知道错误的原因是什么?我找到了,我必须从主播机中删除fx:controller我找到了,我必须从anchorpane中删除fx:controller更新以指示代码包中codeIs类
controller
中的第11行?不,它不在包中包含start()的类的名称是什么
出现在您的问题中的方法?@Abra类的名称是Login更新的,以指示codeIs类控制器中的第11行?不,它不在包中包含出现在您的问题中的start()
方法的类的名称是什么?@Abra类的名称是Login