加载fxml javafx8时出错

时间:2016-04-17 14:23:02

标签: exception javafx fxmlloader

我正在尝试加载以下fxml文件。我只是得到一个指向第19行的异常。我可以通过在窗口菜单项中显示预览,在scenebuilder中加载它。起初我以为有一个矩形不能成为堆栈窗口的子项,但这是Oracle用于javadoc和StackPane的示例。是否有已知的最佳实践来调试加载和fxml文件的失败?它标记了reticlefilter stackpane下的第一个孩子。 这两个孩子是带有黄色十字线的浅蓝色矩形。

Preview Image

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

<?import org.cornova.javafx.*?>
<?import javafx.scene.shape.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>

<VBox fx:id="sliceRealEstate" alignment="TOP_CENTER" onMouseDragged="#onMouseDragged" onMousePressed="#onMousePressed" onScroll="#onScroll" onScrollStarted="#onScrollStarted" pickOnBounds="false" stylesheets="@org/cornova/javafx/xpssdr.css" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.cornova.xpssdr.controllers.SliceController">
   <children>
      <HBox fx:id="flagPole" pickOnBounds="false">
         <children>
            <Pane fx:id="flagPane" pickOnBounds="false" stylesheets="@org/cornova/javafx/xpssdr.css">
               <children>
                  <StackPane fx:id="reticleFilter" alignment="BOTTOM_LEFT" pickOnBounds="false">
                     <children>
                        ***<Rectangle fx:id="filter" fill="#3670ad" height="40.0" opacity="0.38" width="30.0" StackPane.alignment="CENTER" />***
                        <Rectangle fx:id="reticle" fill="#e8e82f" height="40.0" width="2.0" StackPane.alignment="CENTER" />
                     </children>
                  </StackPane>
                  <HBox fx:id="flag">
                     <children>
                        <VBox alignment="TOP_CENTER" spacing="10.0" style="-fx-background-color: black;" HBox.hgrow="NEVER">
                           <children>
                              <Button fx:id="close" mnemonicParsing="false" onAction="#close" text="cls">
                                 <font>
                                    <Font size="10.0" />
                                 </font>
                              </Button>
                              <Button fx:id="lock" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#lock" text="lck">
                                 <font>
                                    <Font size="10.0" />
                                 </font>
                              </Button>
                              <Button fx:id="record" layoutX="10.0" layoutY="29.0" mnemonicParsing="false" onAction="#record" text="rec">
                                 <font>
                                    <Font size="10.0" />
                                 </font>
                              </Button>
                              <Button fx:id="play" layoutX="10.0" layoutY="48.0" mnemonicParsing="false" onAction="#play" text="play">
                                 <font>
                                    <Font size="10.0" />
                                 </font>
                              </Button>
                           </children>
                        </VBox>
                        <VBox alignment="CENTER" style="-fx-background-color: black;" HBox.hgrow="NEVER">
                           <children>
                              <HBox alignment="CENTER" VBox.vgrow="ALWAYS">
                                 <children>
                                    <VBox alignment="CENTER" HBox.hgrow="NEVER">
                                       <children>
                                          <HBox alignment="CENTER" VBox.vgrow="NEVER">
                                             <children>
                                                <VBox alignment="TOP_CENTER">
                                                   <children>
                                                      <ComboBox fx:id="rcvsrc" prefWidth="65.0" />
                                                      <ComboBox fx:id="txsrc" prefWidth="65.0" />
                                                   </children>
                                                </VBox>
                                                <Label fx:id="filterwidth" text="200" HBox.hgrow="NEVER" />
                                             </children>
                                          </HBox>
                                          <HBox alignment="CENTER_LEFT" fillHeight="false" VBox.vgrow="NEVER">
                                             <children>
                                                <Label fx:id="nbon" text="nb" />
                                                <Label fx:id="apfon" text="nr" />
                                                <Label fx:id="nron" text="apf" />
                                                <Label fx:id="qskon" text="qsk" />
                                             </children>
                                          </HBox>
                                       </children>
                                    </VBox>
                                    <HBox HBox.hgrow="ALWAYS">
                                       <children>
                                          <Label fx:id="txindicator" alignment="CENTER" contentDisplay="CENTER" graphicTextGap="0.0" styleClass="largeindicators" text="TX" textAlignment="CENTER" textFill="RED">
                                             <font>
                                                <Font size="28.0" />
                                             </font>
                                          </Label>
                                          <Label fx:id="sliceind" alignment="CENTER" contentDisplay="CENTER" styleClass="largeindicators" text="A" textAlignment="CENTER">
                                             <font>
                                                <Font size="27.0" />
                                             </font>
                                          </Label>
                                       </children>
                                    </HBox>
                                 </children>
                              </HBox>
                              <VBox VBox.vgrow="NEVER">
                                 <children>
                                    <HBox alignment="CENTER" VBox.vgrow="NEVER">
                                       <children>
                                          <Label fx:id="signalLevel" alignment="CENTER" styleClass="mediumindicators" text="S9" HBox.hgrow="NEVER">
                                             <opaqueInsets>
                                                <Insets />
                                             </opaqueInsets>
                                          </Label>
                                          <Label fx:id="signalplus" text="+20" />
                                          <TextField fx:id="frequency" maxHeight="-Infinity" maxWidth="161.0" onAction="#onFrequencyChange" onMouseEntered="#scale" prefHeight="40.0" prefWidth="144.0" promptText="144.123456" styleClass="mediumindicators" />
                                       </children>
                                    </HBox>
                                 </children>
                              </VBox>
                              <HBox VBox.vgrow="NEVER">
                                 <children>
                                    <ButtonBar buttonMinWidth="30.0" HBox.hgrow="NEVER">
                                      <buttons>
                                        <Button fx:id="spkr" mnemonicParsing="false" onAction="#displaySpkrSubmenu" text="spkr">
                                             <font>
                                                <Font size="10.0" />
                                             </font>
                                          </Button>
                                          <Button fx:id="dsp" mnemonicParsing="false" onAction="#displayDSPSubmenu" text="dsp">
                                             <font>
                                                <Font size="10.0" />
                                             </font>
                                          </Button>
                                          <Button fx:id="mode" layoutX="125.0" layoutY="17.0" mnemonicParsing="false" onAction="#displayModeSubmenu" text="rtty">
                                             <font>
                                                <Font size="10.0" />
                                             </font>
                                          </Button>
                                          <Button layoutX="220.0" layoutY="17.0" mnemonicParsing="false" onAction="#displayXRITSubmenu" text="x/rit" fx:id="xrit">
                                             <font>
                                                <Font size="10.0" />
                                             </font>
                                          </Button>
                                          <Button fx:id="dax" layoutX="315.0" layoutY="17.0" mnemonicParsing="false" onAction="#displayDAXSubmenu" text="dax">
                                             <font>
                                                <Font size="10.0" />
                                             </font>
                                          </Button>
                                      </buttons>
                                       <padding>
                                          <Insets bottom="5.0" right="5.0" top="5.0" />
                                       </padding>
                                    </ButtonBar>
                                 </children>
                              </HBox>
                           </children>
                        </VBox>
                     </children>
                  </HBox>
               </children>
            </Pane>
         </children>
      </HBox>
   </children>
</VBox>

其他信息:

来自例外的确切文字

11:11:24.191 [nioEventLoopGroup-2-3] DEBUG org.cornova.xpssdr.views.SliceView - javafx.fxml.LoadException: 
file:/home/walt/NetBeansProjects/XPSSDR/dist/run293699722/XPSSDR.jar!/SliceFlag.fxml:19

执行加载的代码。

public VBox create() throws IOException {
    VBox pane = null;
    try {
        pane = sliceLoader.load();
        controller = sliceLoader.getController();
        controller.setRadio(radio);
        controller.setPan(pan);
        controller = sliceLoader.getController();
        controller.setPanadapter(pan);
        controller.setParent(this);
        controller.setSlice(slice);
        wire();
        Platform.runLater(() -> {
            controller.wire();
        });
    } catch (Exception e) {
        if (log.isDebugEnabled()) {
            log.debug(e.getLocalizedMessage());
            log.debug(e.getMessage());
            log.debug(e.toString());
        }
    }

    return pane;
}

错误实际上是在控制器的构造函数中。昨晚我试图让屏幕显示,当它是一个ResizableCanvas时,我决定将它改为Rectangle,这样它只需要一个fill()。由于这是一个现有的应用程序和现有的控制器,就像它一样,我没有从SceneBuilder的View样本控制器创建它,并且无意中没有更改控制器构造函数中的@FXML。在FXMLLoader.java中,我最终能够将其追踪到它试图调用某些东西的程度,即控制器。奇怪的是,它指向了错误的控制器,我确认在fxml中是正确的。困惑但不是现在的困惑。你评论詹姆斯总是有一个堆栈跟踪。不,很多时候没有。它只是让我感到震惊,也许我错过了一些关于调试这些问题的最佳实践(JavaFX fxml加载器问题,这些问题在过去的几天里我已经有过几次。

0 个答案:

没有答案