程序开始运行时,在另一个fxml文件上的anchorPane上打开fxml文件

时间:2018-12-03 19:13:02

标签: java javafx

随着程序开始运行,我试图在另一个fxml文件中打开的anchorPane中打开fxml文件。这是主要的fxml文件。

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

<?import javafx.scene.layout.AnchorPane?>


<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" 
minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" 
xmlns="http://javafx.com/javafx/8.0.172-ea" 
xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <AnchorPane prefHeight="400.0" fx:id="leftScreen" prefWidth="150.0" />
      <AnchorPane layoutX="150.0" layoutY="1.0" prefHeight="400.0" 
      prefWidth="300.0" />
      <AnchorPane layoutX="450.0" prefHeight="400.0" prefWidth="150.0" />
   </children>
</AnchorPane>

这是我要在主fxml文件中的第一个子anchorPane上打开的第二个fxml文件。

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

<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>

<AnchorPane prefHeight="400.0" prefWidth="150.0" 
xmlns="http://javafx.com/javafx/8.0.172-ea" 
xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <GridPane layoutY="-1.0" prefHeight="400.0" prefWidth="150.0">
        <columnConstraints>
          <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" 
          prefWidth="100.0" />
        </columnConstraints>
        <rowConstraints>
          <RowConstraints maxHeight="149.0" minHeight="10.0" 
          prefHeight="94.0" vgrow="SOMETIMES" />
          <RowConstraints maxHeight="287.0" minHeight="10.0" 
          prefHeight="230.0" vgrow="SOMETIMES" />
          <RowConstraints maxHeight="65.0" minHeight="10.0" 
          prefHeight="65.0" vgrow="SOMETIMES" />
        </rowConstraints>
         <children>
            <AnchorPane prefHeight="200.0" prefWidth="200.0">
               <children>
                  <Button layoutX="49.0" layoutY="38.0" 
                  mnemonicParsing="false" text="Button" />
               </children></AnchorPane>
            <AnchorPane prefHeight="200.0" prefWidth="200.0" 
            GridPane.rowIndex="1" />
            <AnchorPane prefHeight="200.0" prefWidth="200.0" 
            GridPane.rowIndex="2" />
         </children>
      </GridPane>
   </children>
</AnchorPane>

我尝试执行此操作的原因是从多个控制器而不是单个很长的控制器运行程序。我该怎么办?

0 个答案:

没有答案