加载FXML文件时出现NullPointerException

时间:2015-02-26 21:24:48

标签: javafx-8 fxml fxmlloader

所以,我已经做了很多次没有问题但是这次当我将fxml及其控制器从一个项目移动到另一个项目时我无法加载它。到fxml的目录很好,fxml文件中的目录到控制器也不错,我不明白为什么加载它有问题。

enter image description here

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

<?import javafx.scene.effect.*?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.BorderPane?>

<BorderPane fx:id="borderPane" prefHeight="340.0" prefWidth="230.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.controller.tomaszm.SpokenNumbersController">
   <center>
      <Pane prefHeight="389.0" prefWidth="241.0" BorderPane.alignment="CENTER">
         <children>
            <Pane layoutY="233.0" prefHeight="75.0" prefWidth="244.0" style="-fx-background-color: linear-gradient( from 0.0% 0.0% to 100.0% 100.0%, rgba(255,255,255,0.1034482792019844) 0.0, rgba(241,255,20,0.2068965584039688) 100.0);">
               <children>
                  <CheckBox layoutX="5.0" layoutY="55.0" mnemonicParsing="false" opacity="0.8" text="Test me when finished" />
                  <ToggleButton fx:id="toggbuttSTART" layoutX="5.0" layoutY="5.0" mnemonicParsing="false" onAction="#toggbuttSTARTAction" opacity="0.94" prefHeight="42.0" prefWidth="230.0" text="START">
                     <cursor>
                        <Cursor fx:constant="HAND" />
                     </cursor>
                     <effect>
                        <InnerShadow height="35.83" radius="21.119999999999997" width="50.65" />
                     </effect>
                     <font>
                        <Font name="System Bold" size="12.0" />
                     </font>
                  </ToggleButton>
               </children>
            </Pane>
            <AnchorPane layoutY="145.0" prefHeight="88.0" prefWidth="245.0" style="-fx-background-color: linear-gradient( from 0.0% 0.0% to 100.0% 100.0%, rgba(255,255,255,0.10000000149011612) 0.0, rgba(6,56,255,0.30000000298023224) 100.0);">
               <children>
                  <CheckBox fx:id="checkExtra" layoutX="5.0" mnemonicParsing="false" onAction="#checkExtraAction" opacity="0.96" prefHeight="23.0" prefWidth="230.0" text="Make extra breaks">
                     <padding>
                        <Insets bottom="15.0" left="4.0" top="1.0" />
                     </padding>
                  </CheckBox>
                  <Pane fx:id="breaksPane" disable="true" layoutY="32.0" prefHeight="56.0" prefWidth="230.0">
                     <children>
                        <ComboBox fx:id="comboboxEach" layoutX="5.0" layoutY="20.0" prefHeight="25.0" prefWidth="90.0" promptText="each" />
                        <ComboBox fx:id="comboboxExtraInterval" layoutX="116.0" layoutY="20.0" onAction="#checkExtraAction" prefHeight="25.0" prefWidth="90.0" promptText="interval" />
                        <Label layoutX="5.0" text="Cycle lenght:">
                           <font>
                              <Font name="System Italic" size="12.0" />
                           </font>
                        </Label>
                        <Label layoutX="116.0" layoutY="2.0" text="Delay:">
                           <font>
                              <Font name="System Italic" size="12.0" />
                           </font>
                        </Label>
                     </children>
                  </Pane>
               </children>
            </AnchorPane>
            <AnchorPane prefHeight="68.0" prefWidth="245.0" style="-fx-background-color: linear-gradient( from 0.0% 0.0% to 100.0% 100.0%, rgba(255,255,255,0.10000000149011612) 0.0, rgba(255,0,0,0.22000000298023224) 100.0);">
               <children>
                  <ComboBox fx:id="comboboxInterval" layoutX="5.0" layoutY="27.0" opacity="0.8" prefHeight="25.0" prefWidth="152.0" promptText="interval" AnchorPane.leftAnchor="8.0" />
                  <Label layoutX="5.0" layoutY="6.0" opacity="0.9" prefHeight="17.0" prefWidth="77.0" text="Interval:" AnchorPane.leftAnchor="7.0">
                     <font>
                        <Font name="System Bold" size="12.0" />
                     </font>
                  </Label>
               </children>
            </AnchorPane>
            <Pane layoutY="68.0" prefHeight="77.0" prefWidth="247.0" style="-fx-background-color: linear-gradient( from 0.0% 0.0% to 100.0% 100.0%, rgba(255,255,255,0.10000000149011612) 0.0, rgba(48,213,48,0.30000000298023224) 100.0);">
               <children>
                  <Slider fx:id="sliderCountdown" layoutX="2.0" layoutY="27.0" majorTickUnit="10.0" max="500.0" minorTickCount="0" prefHeight="37.0" prefWidth="179.0" showTickLabels="true" showTickMarks="true" snapToTicks="true" value="100.0" />
                  <Button fx:id="buttPlus" alignment="CENTER" layoutX="177.0" layoutY="25.0" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#buttPlusAction" prefHeight="31.0" prefWidth="31.0" style="-fx-background-insets: 4;" text="+" textFill="RED">
                     <font>
                        <Font size="14.0" />
                     </font>
                  </Button>
                  <Button fx:id="buttMinus" alignment="CENTER" layoutX="201.0" layoutY="25.0" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#buttMinusAction" prefHeight="31.0" prefWidth="31.0" style="-fx-background-insets: 4;" text="–" textFill="RED">
                     <font>
                        <Font size="14.0" />
                     </font>
                  </Button>
                  <Label layoutX="5.0" layoutY="6.0" opacity="0.9" prefHeight="17.0" prefWidth="74.0" text="Countdown:">
                     <font>
                        <Font name="System Bold" size="12.0" />
                     </font>
                  </Label>
                  <Label fx:id="labCountdown" layoutX="81.0" layoutY="6.0" opacity="0.9" text="100" textFill="RED" />
               </children>
            </Pane>
            <Separator layoutY="310.0" opacity="0.5" prefHeight="3.0" prefWidth="241.0" />
         </children>
      </Pane>
   </center>
   <top>
      <MenuBar BorderPane.alignment="CENTER">
        <menus>
          <Menu mnemonicParsing="false" text="Options">
            <items>
                  <Menu mnemonicParsing="false" text="Language">
                     <items>
                        <RadioMenuItem fx:id="radiomenuPolish" mnemonicParsing="false" onAction="#selectLanguageAction" selected="true" text="Polski">
                           <toggleGroup>
                              <ToggleGroup fx:id="languageGroup" />
                           </toggleGroup>
                        </RadioMenuItem>
                        <RadioMenuItem fx:id="radiomenuEnglish" mnemonicParsing="false" onAction="#selectLanguageAction" text="English" toggleGroup="$languageGroup" />
                        <RadioMenuItem fx:id="radiomenuDeutsch" mnemonicParsing="false" onAction="#selectLanguageAction" text="Deutsch" toggleGroup="$languageGroup" />
                        <RadioMenuItem fx:id="radiomenuChinesse" mnemonicParsing="false" onAction="#selectLanguageAction" text="Chinesse" toggleGroup="$languageGroup" />
                     </items>
                  </Menu>
              <MenuItem mnemonicParsing="false" text="Close" />
            </items>
          </Menu>
          <Menu mnemonicParsing="false" text="Help">
            <items>
              <MenuItem mnemonicParsing="false" text="About" />
            </items>
          </Menu>
        </menus>
      </MenuBar>
   </top>
   <bottom>
      <HBox opacity="0.6" prefHeight="10.0" prefWidth="241.0" BorderPane.alignment="CENTER">
         <children>
            <Label prefHeight="4.0" prefWidth="74.0" text="Counted digits: ">
               <font>
                  <Font name="Cambria" size="11.0" />
               </font>
            </Label>
            <Label fx:id="labNumber" prefHeight="14.0" prefWidth="73.0" text="0">
               <font>
                  <Font name="Cambria" size="11.0" />
               </font>
            </Label>
         </children>
      </HBox>
   </bottom>
</BorderPane>

0 个答案:

没有答案