JavaFX-Text在编译时比在SceneBuilder中更大

JavaFX-Text在编译时比在SceneBuilder中更大,javafx,scenebuilder,Javafx,Scenebuilder,我在JavaFX中遇到了一个问题。运行程序时文本比在SceneBuilder中的文本大 运行程序: SceneBuilder: 这是fxml文件: 请帮我解决这个问题。在另一台PC上,它可以正常工作。不同的JavaFX版本/OS的字体大小/精确控制大小可能不同。这里不应该使用绝对位置。我建议使用一种布局,根据孩子们的大小来选择他们的位置。合适的布局应该是GridPane(如果您想确保单元格数量保持不变,而不管字体大小、窗口大小等,ComboBox应该水平对齐)或FlowPane(如果您希

我在JavaFX中遇到了一个问题。运行程序时文本比在SceneBuilder中的文本大

运行程序: SceneBuilder:

这是fxml文件:



请帮我解决这个问题。在另一台PC上,它可以正常工作。

不同的JavaFX版本/OS的字体大小/精确控制大小可能不同。这里不应该使用绝对位置。我建议使用一种布局,根据孩子们的大小来选择他们的位置。合适的布局应该是
GridPane
(如果您想确保单元格数量保持不变,而不管字体大小、窗口大小等,
ComboBox
应该水平对齐)或
FlowPane
(如果您希望将一组类似于文本的
组合框
es放置在一起,而不关心水平对齐方式或每行
组合框
es的确切数量)

。。。
...
。。。
...

谢谢,我为应用程序制作了一个CSS样式,用于设置所有文本的文本大小。它帮助我解决JavaFX版本的这个问题。我还使用了您关于布局的提示。
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="200.0" minWidth="450.0" prefHeight="200.0"prefWidth="450.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <GridPane layoutX="24.0" layoutY="14.0" prefWidth="406.0" AnchorPane.bottomAnchor="60.0" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" AnchorPane.topAnchor="5.0">
        <columnConstraints>
          <ColumnConstraints hgrow="SOMETIMES" maxWidth="100.0" minWidth="10.0" prefWidth="100.0" />
          <ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="180.0" />
            <ColumnConstraints hgrow="SOMETIMES" maxWidth="85.0" minWidth="10.0" prefWidth="85.0" />
        </columnConstraints>
        <rowConstraints>
          <RowConstraints minHeight="10.0" prefHeight="40.0" vgrow="SOMETIMES" />
          <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
            <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
        </rowConstraints>
         <children>
            <Label text="Rozszerzenie" />
            <Label text="Główny katalog" GridPane.rowIndex="1" />
            <Label text="Katolog docelowy" GridPane.rowIndex="2" />
            <Button mnemonicParsing="false" onAction="#chooseMainDirectory" text="Przeszukaj" GridPane.columnIndex="2" GridPane.rowIndex="1">
               <GridPane.margin>
                  <Insets left="10.0" />
               </GridPane.margin>
            </Button>
            <Button mnemonicParsing="false" onAction="#chooseTargetDirectory" text="Przeszukaj" GridPane.columnIndex="2" GridPane.rowIndex="2">
               <GridPane.margin>
                  <Insets left="10.0" />
               </GridPane.margin>
            </Button>
            <TextField fx:id="mainDirectory" GridPane.columnIndex="1" GridPane.rowIndex="1" />
            <TextField fx:id="targetDirectory" GridPane.columnIndex="1" GridPane.rowIndex="2" />
            <AnchorPane fx:id="choiceDeck" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1">
               <children>
                  <CheckBox layoutY="6.0" mnemonicParsing="false" text=".jpg" />
                  <CheckBox layoutX="48.0" layoutY="6.0" mnemonicParsing="false" text=".jpeg" />
              <CheckBox layoutX="104.0" layoutY="6.0" mnemonicParsing="false" text=".gif" />
                  <CheckBox layoutX="150.0" layoutY="6.0" mnemonicParsing="false" text=".bmp" />
                  <CheckBox layoutY="30.0" mnemonicParsing="false" text=".png" />
                  <CheckBox layoutX="49.0" layoutY="30.0" mnemonicParsing="false" text=".tiff" />
               </children>
            </AnchorPane>
         </children>
      </GridPane>
      <Button layoutX="368.0" layoutY="161.0" mnemonicParsing="false" onAction="#confirm" text="Zatwierdź" AnchorPane.bottomAnchor="14.0" AnchorPane.rightAnchor="14.0" />
      <Button layoutX="14.0" layoutY="161.0" mnemonicParsing="false" onAction="#cancel" text="Anuluj" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0" />
   </children>
</AnchorPane>