JavaFX FXML not working same way as in SceneBuilder (sceencast)

非 Y 不嫁゛ 提交于 2019-12-13 18:13:45

问题


I've got this FXML that is working perfectly in SceneBuilder Preview and acts completely different on NetBeans JavaFX Sample Application (so there is nothing extra that could break it's behaviour). (see sceencast)

I need that 2 TitledPanes to autoresize (half and half) according with the Window (as it works in the SceneBuilder Preview).

<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefWidth="798.0" xmlns:fx="http://javafx.com/fxml" fx:controller="javafxapplication2.Sample">
  <children>
    <VBox id="vBox1" prefWidth="770.0" spacing="25.0" AnchorPane.bottomAnchor="25.0" AnchorPane.leftAnchor="25.0" AnchorPane.rightAnchor="25.0" AnchorPane.topAnchor="25.0">
      <children>
        <TitledPane id="titledPane1" fx:id="test" prefWidth="748.0" text="Admin" VBox.vgrow="ALWAYS">
          <content>
            <AnchorPane id="Content" minHeight="0.0" minWidth="0.0">
              <children>
                <TableView id="tableView1" prefWidth="718.0" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0" />
              </children>
            </AnchorPane>
          </content>
        </TitledPane>
        <TitledPane id="titledPane2" prefWidth="748.0" text="Resellers" VBox.vgrow="ALWAYS">
          <content>
            <AnchorPane id="Content" minWidth="0.0" prefWidth="744.0">
              <children>
                <TableView id="tableView2" prefWidth="200.0" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0" />
              </children>
            </AnchorPane>
          </content>
        </TitledPane>
      </children>
    </VBox>
  </children>
</AnchorPane>

回答1:


The SceneBuilder Preview and NetBeans JavaFX Sample Application are using different versions of JavaFX. Probably the SceneBuilder is using 2.1 and NetBeans 2.0.2. Upgrade the version of the app, either by upgrading the Java version of your machine or importing the new jfxrt.jar version to your classpath (ie. into netbeans app libraries).



来源:https://stackoverflow.com/questions/10473074/javafx-fxml-not-working-same-way-as-in-scenebuilder-sceencast

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!