JavaFX Loader没有加载

时间:2017-03-26 17:26:47

标签: javafx fxmlloader

这是我的主要班级:

public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("mainmenu.fxml"));
    primaryStage.setTitle("Horse Manager");
    primaryStage.setScene(new Scene(root,400,600));
    primaryStage.show();

}

public static void main(String[] args) {
    launch(args);
}


}

我收到了这个错误:

Exception in Application start method
Exception in thread "main" 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$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
Caused by: javafx.fxml.LoadException: 
/C:/Users/nikit/IdeaProjects/SEPM/out/production/SEPM/sepm/ss17/e1526589/GUI/XMLs/mainmenu.fxml:42

这是用SceneBuilder制作的fxml:

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

<?import javafx.scene.control.Accordion?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.TitledPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Text?>

<BorderPane fx:id="root" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="500" minWidth="500" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sepm.ss17.e1526589.GUI.XMLs.Controllers.MainMenuController">
    <top>
      <MenuBar BorderPane.alignment="CENTER">
        <menus>
          <Menu mnemonicParsing="false" text="File">
            <items>
              <MenuItem mnemonicParsing="false" text="Close" />
            </items>
          </Menu>
          <Menu mnemonicParsing="false" text="Edit">
            <items>
              <MenuItem mnemonicParsing="false" text="Delete" />
            </items>
          </Menu>
          <Menu mnemonicParsing="false" text="Help">
            <items>
              <MenuItem mnemonicParsing="false" text="About" />
            </items>
          </Menu>
        </menus>
      </MenuBar>
    </top>
    <left>
      <Accordion BorderPane.alignment="CENTER">
        <panes>
            <TitledPane prefHeight="200.0" prefWidth="200.0" text="Boxes">
               <content>
                  <VBox prefHeight="200.0" prefWidth="100.0">
                     <children>
                        <Button fx:id="boxSearch" mnemonicParsing="false" prefWidth="250.0" text="Search" />
                        <Button fx:id="boxCD" mnemonicParsing="false" prefWidth="250.0" text="Create/Delete Box" />
                        <Button fx:id="boxUpdate" mnemonicParsing="false" prefWidth="250.0" text="Update Box" />
                     </children>
                  </VBox>
               </content>
            </TitledPane>
          <TitledPane animated="false" text="Customers">
               <content>
                  <VBox prefHeight="200.0" prefWidth="100.0">
                     <children>
                        <Button fx:id="customerSearch" mnemonicParsing="false" prefWidth="250.0" text="Search" />
                        <Button fx:id="customerCD" mnemonicParsing="false" prefWidth="250.0" text="Customer New/Old" />
                        <Button fx:id="customerUpdate" mnemonicParsing="false" prefWidth="250.0" text="Update Cutomer" />
                     </children>
                  </VBox>
               </content>
            </TitledPane>
          <TitledPane animated="false" text="Reservations">
               <content>
                  <VBox prefHeight="200.0" prefWidth="100.0">
                     <children>
                        <Button fx:id="reservationsSearch" mnemonicParsing="false" prefWidth="250.0" text="Search" />
                        <Button fx:id="reservationsCD" mnemonicParsing="false" prefWidth="250.0" text="Create/Delete Reservations" />
                        <Button fx:id="reservationsUpdate" mnemonicParsing="false" prefWidth="250.0" text="Update Reservations" />
                     </children>
                  </VBox>
               </content>
            </TitledPane>
            <TitledPane prefHeight="200.0" prefWidth="200.0" text="Bills">
               <content>
                  <VBox prefHeight="200.0" prefWidth="100.0">
                     <children>
                        <Button fx:id="billsSearch" mnemonicParsing="false" prefWidth="250.0" text="Search" />
                        <Button fx:id="billsCD" mnemonicParsing="false" prefWidth="250.0" text="Create/Delete Bills" />
                        <Button fx:id="billsUpdate" mnemonicParsing="false" prefWidth="250.0" text="Update Bills" />
                     </children>
                  </VBox>
               </content>
            </TitledPane>
            <TitledPane prefHeight="200.0" prefWidth="200.0" text="Statistics">
               <content>
                  <VBox prefHeight="200.0" prefWidth="100.0">
                     <children>
                        <Button mnemonicParsing="false" prefWidth="250.0" text="Search" />
                        <Button mnemonicParsing="false" prefWidth="250.0" text="Create/Delete Box" />
                        <Button mnemonicParsing="false" prefWidth="250.0" text="Update Box" />
                     </children>
                  </VBox>
               </content>
            </TitledPane>
        </panes>
      </Accordion>
    </left>
    <center>
      <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Welcome to Horse        Manager" BorderPane.alignment="CENTER" />
   </center>
</BorderPane>

我的路径有效,我不知道错误发生了什么,因为我能说的.load函数。请帮忙

0 个答案:

没有答案