不动产;“可访问文件”;javafx中不存在或为只读错误

不动产;“可访问文件”;javafx中不存在或为只读错误,java,javafx,Java,Javafx,伙计们,当我试图创建一个新的舞台并获取其控制器时,程序将给我留下以下错误: Property "accessibleRole" does not exist or is read-only 我已经在互联网上搜索了一个修复程序,但似乎以前没有人发现这个错误 以下是我将创建舞台的功能: public static MainSceneController mainSceneController; public MainSceneController changeToMainScene() thro

伙计们,当我试图创建一个新的舞台并获取其控制器时,程序将给我留下以下错误:

Property "accessibleRole" does not exist or is read-only
我已经在互联网上搜索了一个修复程序,但似乎以前没有人发现这个错误

以下是我将创建舞台的功能:

public static MainSceneController mainSceneController;

public MainSceneController changeToMainScene() throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("MainScene.fxml"));
        Parent root = (Parent)fxmlLoader.load();  //im getting the error on this line
        mainSceneController =  fxmlLoader.getController();
        Stage stage = new Stage();

        stage.setTitle("Test");

        stage.setScene(new Scene(root));
        stage.show();
        return mainSceneController;
    }
我很困惑问题出在哪里

编辑:

以下是fxml文件:

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

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

<fx:root maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="1200.0" type="BorderPane" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ir.pgforums.MainSceneController">
   <top>
      <HBox prefHeight="54.0" prefWidth="800.0" BorderPane.alignment="CENTER" />
   </top>
   <left>
      <SplitPane dividerPositions="0.13528336380255943" orientation="VERTICAL" prefHeight="200.0" prefWidth="160.0" BorderPane.alignment="CENTER">
        <items>
          <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0" />
          <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0" />
        </items>
      </SplitPane>
   </left>
   <center>
      <SplitPane prefHeight="160.0" prefWidth="200.0" BorderPane.alignment="CENTER">
         <items>
            <SplitPane dividerPositions="0.13419117647058823" orientation="VERTICAL" prefHeight="200.0" prefWidth="160.0">
              <items>
                <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0" style="-fx-border-image-wi: 20px; -fx-border-radius: 5px;">
                     <children>
                        <Slider accessibleRole="TREE_VIEW" blockIncrement="5.0" layoutX="111.0" layoutY="35.0" majorTickUnit="5.0" max="24.0" min="1.0" minorTickCount="4" nodeOrientation="RIGHT_TO_LEFT" prefHeight="14.0" prefWidth="1038.0" showTickLabels="true" showTickMarks="true" snapToTicks="true" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="28.0" />
                        <DatePicker layoutX="14.0" layoutY="2.0" />
                     </children></AnchorPane>
                <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
                     <children>
                        <SplitPane dividerPositions="0.29797979797979796" layoutX="202.0" layoutY="147.0" prefHeight="468.0" prefWidth="638.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                          <items>
                            <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
                                 <children>
                                    <SplitPane layoutX="62.0" layoutY="188.0" orientation="VERTICAL" prefHeight="466.0" prefWidth="306.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                                      <items>
                                        <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0" style="-fx-border-style: none;">
                                             <children>
                                                <VBox layoutX="102.0" layoutY="88.0" prefHeight="464.0" prefWidth="304.0" style="-fx-border-style: none;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                                                   <children>
                                                      <StackPane prefHeight="336.0" prefWidth="304.0" style="-fx-border-style: none;" />
                                                      <TextField promptText="Summary">
                                                         <VBox.margin>
                                                            <Insets left="5.0" right="5.0" />
                                                         </VBox.margin>
                                                      </TextField>
                                                      <TextArea prefHeight="99.0" prefWidth="294.0" promptText="Description">
                                                         <VBox.margin>
                                                            <Insets bottom="10.0" left="5.0" right="5.0" top="10.0" />
                                                         </VBox.margin>
                                                      </TextArea>
                                                      <GridPane prefWidth="304.0">
                                                        <columnConstraints>
                                                          <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
                                                          <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
                                                            <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
                                                        </columnConstraints>
                                                        <rowConstraints>
                                                          <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                                                          <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                                                        </rowConstraints>
                                                         <children>
                                                            <Button mnemonicParsing="false" prefHeight="25.0" prefWidth="81.0" style="-fx-background-radius: 100px;" text="Commit" textAlignment="CENTER" GridPane.columnIndex="1" />
                                                         </children>
                                                      </GridPane>
                                                   </children>
                                                </VBox>
                                             </children>
                                          </AnchorPane>
                                      </items>
                                    </SplitPane>
                                 </children></AnchorPane>
                            <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="797.0" />
                          </items>
                        </SplitPane>
                     </children>
                  </AnchorPane>
              </items>
            </SplitPane>
         </items>
      </SplitPane>
   </center>
</fx:root>


好的,我已经添加了FXML,您使用什么java(fx)版本来运行代码?java8中的JavaFX2似乎有点奇怪,因为java8包含JavaFX8。由于java(fx)8 update 40中添加了可访问的角色,
FXMLLoader
可能无法找到所需的方法。您可以通过访问不使用fxml创建的
节点的
accessibleRole
来测试这一点。在这种情况下,我希望有更好的错误消息。好的,我添加了fxmlWhat java(fx)版本,您使用它来运行代码?java8中的JavaFX2似乎有点奇怪,因为java8包含JavaFX8。由于java(fx)8 update 40中添加了可访问的角色,
FXMLLoader
可能无法找到所需的方法。您可以通过访问不使用fxml创建的
节点的
accessibleRole
来测试这一点。在这种情况下,我希望有更好的错误消息。