javafx程序有问题吗

javafx程序有问题吗,javafx,Javafx,我正在创建一个javafx桌面应用程序。我遇到的问题是,如果我在fxml文件中添加了一个控制器,那么这些控件就会以某种方式消失。该程序使用淡入淡出转换在fxml文件之间切换 AnchorPane reorderLevels,purchaseorder,onlineSales,generalLedger ,cashBook,payments,departmentalTransfers ,purchaseInvoice ,productMantainance, bra

我正在创建一个javafx桌面应用程序。我遇到的问题是,如果我在fxml文件中添加了一个控制器,那么这些控件就会以某种方式消失。该程序使用淡入淡出转换在fxml文件之间切换

AnchorPane reorderLevels,purchaseorder,onlineSales,generalLedger
    ,cashBook,payments,departmentalTransfers
    ,purchaseInvoice
    ,productMantainance,
    branchTransfers,stockMovement,invoiceRegistration,stockTake;

    //---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

@Override
public void initialize(URL url, ResourceBundle rb) {
    //load all the fxml screens when the buttons are clicked
    try {
        //screens for the application
         reorderLevels = FXMLLoader.load(getClass().getResource("ReorderLevels.fxml"));
         purchaseorder = FXMLLoader.load(getClass().getResource("PurchaseOrder.fxml"));
         onlineSales = FXMLLoader.load(getClass().getResource("OnlineSales.fxml"));
         generalLedger = FXMLLoader.load(getClass().getResource("GeneralLedger.fxml"));
         cashBook = FXMLLoader.load(getClass().getResource("CashBook.fxml"));
         departmentalTransfers = FXMLLoader.load(getClass().getResource("DepartmentalTransfers.fxml"));
         purchaseInvoice = FXMLLoader.load(getClass().getResource("PurchaseInvoice.fxml"));
         productMantainance = FXMLLoader.load(getClass().getResource("ProductMantainance.fxml"));
         branchTransfers = FXMLLoader.load(getClass().getResource("BranchTransfers.fxml"));
         stockMovement = FXMLLoader.load(getClass().getResource("StockMovement.fxml"));
         payments = FXMLLoader.load(getClass().getResource("Payments.fxml"));
         invoiceRegistration = FXMLLoader.load(getClass().getResource("InvoiceRegistration.fxml"));
         stockTake = FXMLLoader.load(getClass().getResource("StockTake.fxml"));
         //set each and every individual node when the buttons are clicked
         setNode(reorderLevels);


    } catch (IOException ex) {
        Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);

    }
}


private void setNode(Node node) {
    holderPane.getChildren().clear();
    holderPane.getChildren().add((Node) node);

    //the transition between the screens
    FadeTransition ft = new FadeTransition(Duration.millis(1));
    ft.setNode(node);
    ft.setFromValue(0.1);
    ft.setToValue(1);
    ft.setCycleCount(1);
    ft.setAutoReverse(false);
    ft.play();

}

 /* screens */



@FXML
private void switchReorderLevels(ActionEvent event) {
    setNode(reorderLevels);

}

@FXML
private void switchOnlineSales(ActionEvent event) {
    setNode(onlineSales);
}

@FXML
private void switchGeneralLedger(ActionEvent event) {
    setNode(generalLedger);
}

@FXML

private void switchPurchaseOrder(ActionEvent event) {

    setNode(purchaseorder);
}

@FXML

private void switchCashBook(ActionEvent event) {

    setNode(cashBook);
}
@FXML
private void switchAlert(ActionEvent event) {
    setNode(purchaseorder);
}


@FXML

private void switchPayments(ActionEvent event) {
    setNode(payments);
}

@FXML
private void switchDepartmentalTransfers(ActionEvent event) {
    setNode(departmentalTransfers);
}

@FXML
private void switchPurchaseInvoice(ActionEvent event) {
    setNode(purchaseInvoice);
}

@FXML
private void switchProductMantainance(ActionEvent event) {
    setNode(productMantainance);
}

@FXML
private void switchBranchTransfers(ActionEvent event) {
    setNode(branchTransfers);
} 

//this is a screen that will displayone of the layouts that will show re order levels

    <AnchorPane id="AnchorPane" prefHeight="713.0" prefWidth="1219.0" style="-fx-background-color: white;" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1">
       <children>
          <Label layoutX="24.0" layoutY="17.0" prefHeight="30.0" prefWidth="285.0" style="-fx-font-size: 20; -fx-font-weight: bold; -fx-text-fill: #7387A8;" text="ReOrder Levels" />
          <Separator layoutX="25.0" layoutY="54.0" prefHeight="5.0" prefWidth="1191.0" />
          <Pane fx:id="tbl_reorderLevels" layoutX="25.0" layoutY="108.0" prefHeight="413.0" prefWidth="1174.0" style="-fx-background-color: #EFEFEF;">
             <children>
                <JFXComboBox fx:id="cmd_reOrder_productCode" layoutX="48.0" layoutY="33.0" prefHeight="25.0" prefWidth="267.0" promptText="Product Code" />
                <JFXTextField fx:id="txt_reOrder_reorderLevel" labelFloat="true" layoutX="48.0" layoutY="91.0" prefHeight="25.0" prefWidth="267.0" promptText="Reorder Level" />
AnchorPane ReorderLevel、purchaseorder、onlineSales、GeneralEdge
、现金簿、付款、部门转账
,购货发票
,生产维护,
分支机构转让、库存转移、发票登记、盘点;
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@凌驾
公共void初始化(URL、ResourceBundle rb){
//单击按钮时加载所有fxml屏幕
试一试{
//应用程序的屏幕
reorderLevels=fxmloader.load(getClass().getResource(“reorderLevels.fxml”);
purchaseorder=fxmloader.load(getClass().getResource(“purchaseorder.fxml”);
onlineSales=FXMLLoader.load(getClass().getResource(“onlineSales.fxml”);
GeneralEdge=FXMLLoader.load(getClass().getResource(“GeneralEdge.fxml”);
cashBook=fxmloader.load(getClass().getResource(“cashBook.fxml”);
DepartmentAltTransfers=FXMLLoader.load(getClass().getResource(“DepartmentAltTransfers.fxml”);
purchaseInvoice=FXMLLoader.load(getClass().getResource(“purchaseInvoice.fxml”);
productMantainance=FXMLLoader.load(getClass().getResource(“productMantainance.fxml”);
branchTransfers=FXMLLoader.load(getClass().getResource(“branchTransfers.fxml”);
stockMovement=FXMLLoader.load(getClass().getResource(“stockMovement.fxml”);
payments=fxmloader.load(getClass().getResource(“payments.fxml”);
invoiceRegistration=FXMLLoader.load(getClass().getResource(“invoiceRegistration.fxml”);
stockTake=fxmloader.load(getClass().getResource(“stockTake.fxml”);
//单击按钮时设置每个节点
setNode(reordlevels);
}捕获(IOEX异常){
Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE,null,ex);
}
}
私有void集合节点(节点节点){
holderPane.getChildren().clear();
holderPane.getChildren().add((节点)节点);
//屏幕之间的过渡
FadeTransition ft=新的FadeTransition(持续时间为毫秒(1));
ft.setNode(节点);
ft.setFromValue(0.1);
ft.setToValue(1);
ft.setCycleCount(1);
ft.setAutoReverse(假);
ft.play();
}
/*屏风*/
@FXML
私有void switchreordlevels(ActionEvent事件){
setNode(reordlevels);
}
@FXML
private void SwitchOnline销售(ActionEvent事件){
setNode(在线销售);
}
@FXML
私有无效开关GeneralEdge(ActionEvent事件){
setNode(generalLedger);
}
@FXML
私有void switchPurchaseOrder(ActionEvent事件){
setNode(采购订单);
}
@FXML
私人作废现金簿(ActionEvent事件){
setNode(现金簿);
}
@FXML
私有void switchAlert(ActionEvent事件){
setNode(采购订单);
}
@FXML
私人付款(ActionEvent事件){
setNode(支付);
}
@FXML
私有无效交换部门转移(ActionEvent事件){
setNode(部门转移);
}
@FXML
私有作废switchPurchaseInvoice(ActionEvent事件){
setNode(采购发票);
}
@FXML
私有void switch产品维护(ActionEvent事件){
setNode(生产维护);
}
@FXML
私有无效交换分支传输(ActionEvent事件){
设置节点(分支传输);
} 
//这是一个屏幕,将显示其中一个布局,显示重新订购级别
//这是具有按钮的根布局,这些按钮将使用淡入淡出过渡在屏幕之间导航

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

<?import com.jfoenix.controls.JFXButton?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.effect.InnerShadow?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<!-- root layout -->

<AnchorPane id="AnchorPane" nodeOrientation="LEFT_TO_RIGHT" prefHeight="623.0" prefWidth="1271.0" style="-fx-background-color: #fff;" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller = "dashboard.FXMLDocumentController">
   <children>
      <Pane layoutX="-2.0" prefHeight="81.0" prefWidth="1272.0" style="-fx-background-color: #0b8dee;" styleClass="head-background" stylesheets="@style.css" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
         <children>
            <Label fx:id="labelEstock" layoutX="204.0" layoutY="-3.0" prefHeight="88.0" prefWidth="536.0" style="-fx-shape: round;" stylesheets="@custom.css" text="Oasys Estock" textFill="WHITE">
               <font>
                  <Font name="Brush Script MT Italic" size="36.0" />
               </font>
            </Label>
           <!-- <ImageView fx:id="imageEstock" fitHeight="110.0" fitWidth="92.0" layoutX="102.0" layoutY="8.0" pickOnBounds="true" preserveRatio="true">
               <image>
                  <Image 

    url="@../../../../AndroidStudioProjects/OasysEstock/app/src/main/res/drawable/fortified_icon.png" />
                   </image>
                </ImageView> --> 
             </children>
          </Pane>
          <VBox layoutY="85.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="518.0" prefWidth="122.0" style="-fx-background-color: #0b8dee; -fx-background-radius: 15;">
             <children>
                <JFXButton id="btnReorderLevels" fx:id="btnReorderLevels" buttonType="RAISED" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" onAction="#switchReorderLevels" prefHeight="47.0" prefWidth="107.0" style="-fx-background-radius: 100;" text="ReOrder Levels" textFill="#f5f0f0">
                   <VBox.margin>
                      <Insets />
                   </VBox.margin>
                   <font>
                      <Font name="Calibri" size="12.0" />
                   </font>
                </JFXButton>
                <JFXButton fx:id="btnInvoiceRegistration" onAction="#switchInvoiceRegistration" prefHeight="25.0" prefWidth="121.0" text="Invoice Registration" textFill="#f8f4f4" />
                <JFXButton fx:id="btnPurchaseOrder" buttonType="RAISED" onAction="#switchPurchaseOrder" prefHeight="34.0" prefWidth="107.0" text="Purchase Order" textFill="#f5f0f0">
                   <font>
                      <Font name="Cambria" size="12.0" />
                   </font>
                </JFXButton>
                <JFXButton fx:id="btnOnlineSales" onAction="#switchOnlineSales" prefHeight="39.0" prefWidth="107.0" text="Online Sales" textFill="#fff9f9">
                   <font>
                      <Font name="Calibri" size="12.0" />
                   </font>
                </JFXButton>
                <JFXButton fx:id="btnGeneralLedger" onAction="#switchGeneralLedger" prefHeight="40.0" prefWidth="108.0" text="General Ledger" textFill="#f2eeee" />
                <JFXButton fx:id="btnCashBook" onAction="#switchCashBook" prefHeight="35.0" prefWidth="104.0" text="Cash Book" textFill="#fffefe" />
                <JFXButton fx:id="btnPayments" buttonType="RAISED" onAction="#switchPayments" prefHeight="25.0" prefWidth="114.0" text="Payments" textFill="#fcf6f6" />
                <JFXButton fx:id="btnDepartmentalTransfers" buttonType="RAISED" layoutX="10.0" layoutY="205.0" onAction="#switchDepartmentalTransfers" prefHeight="25.0" prefWidth="114.0" text="Dept Transfers" textFill="#fcf6f6" />
                <JFXButton fx:id="btnProductMantainance" buttonType="RAISED" layoutX="10.0" layoutY="230.0" onAction="#switchProductMantainance" prefHeight="56.0" prefWidth="121.0" text="Product Mantainance" textFill="#fcf6f6">
                   <font>
                      <Font size="11.0" />
                   </font>
                </JFXButton>
                <JFXButton fx:id="btnPurchaseInvoice" buttonType="RAISED" layoutX="10.0" layoutY="255.0" onAction="#switchPurchaseInvoice" prefHeight="56.0" prefWidth="121.0" text="Purchase Invoice" textFill="#fcf6f6">
                   <font>
                      <Font size="11.0" />
                   </font>
                </JFXButton>
                <JFXButton fx:id="btnBranchTransfers" buttonType="RAISED" layoutX="10.0" layoutY="311.0" onAction="#switchBranchTransfers" prefHeight="56.0" prefWidth="121.0" text="Branch Transfers" textFill="#fcf6f6">
                   <font>
                      <Font size="11.0" />
                   </font>
                </JFXButton>
                <JFXButton fx:id="btnStockMovement" buttonType="RAISED" layoutX="10.0" layoutY="367.0" onAction="#switchStockMovement" prefHeight="56.0" prefWidth="121.0" text="Stock Movement" textFill="#fcf6f6">
                   <font>
                      <Font size="11.0" />
                   </font>
                </JFXButton>
                <JFXButton fx:id="btnStockTake" buttonType="RAISED" layoutX="10.0" layoutY="448.0" onAction="#switchStockTake" prefHeight="56.0" prefWidth="121.0" text="Stock Take" textFill="#fcf6f6">
                   <font>
                      <Font size="11.0" />
                   </font>
                </JFXButton>
             </children>
             <effect>
                <InnerShadow blurType="TWO_PASS_BOX" choke="0.58" color="#212122" height="26.69" radius="10.620000000000001" width="17.79" />
             </effect>
          </VBox>
          <AnchorPane fx:id="holderPane" layoutX="125.0" layoutY="96.0" prefHeight="507.0" prefWidth="1134.0"/>
       </children>
    </AnchorPane>


这些控件是否也可能是
holderPane
的子控件?如果不描述具体发生了什么,请添加场景结构(=允许您再现问题的最小fxml)。好的,控件是achor窗格的子控件。下面是将显示的其中一个屏幕的结构。“添加新控制器”是否意味着从各种
onAction
事件调用
setNode()
?究竟什么消失了?这是否意味着最终结果是一个没有任何可见内容的场景?是的,如果我在fxml中放置了一个onAction,那么该场景不会显示任何内容。或者如果我在控制器中这样做,同样的事情也会发生。如果我在锚定窗格中添加控制器,那么场景中也不会显示任何内容。注意:
窗格
锚定窗格
未指定锚定是最糟糕的布局