【问题标题】:JavaFx GridPane layout how to set margin for an element in row?JavaFx GridPane 布局如何为行中的元素设置边距?
【发布时间】:2015-12-14 13:36:45
【问题描述】:

我正在使用 GridPane 布局在我的应用程序中定位内容。我想知道如何为行中的元素设置边距

         GridPane.setConstraints(chip5, 1, 1, 1, 1, HPos.RIGHT, VPos.TOP); //I want to set 
       //  margin for chip5 from top (for example 5px)

在 GridPane 中可以吗?

【问题讨论】:

    标签: javafx margin gridpane


    【解决方案1】:

    在 FXML 中,你可以这样做:

    <TextField fx:id="txtFirstName" GridPane.rowIndex="0" GridPane.columnIndex="1">
        <GridPane.margin>
            <Insets right="30"/>
        </GridPane.margin>
    </TextField>
    

    【讨论】:

      【解决方案2】:

      您可以为任何特定的Node 设置边距:

      GridPane.setMargin(chip5, new Insets(5, 0, 0, 0));
      

      【讨论】:

        猜你喜欢
        • 2020-11-01
        • 2013-06-24
        • 1970-01-01
        • 2014-12-11
        • 2012-09-30
        • 2013-05-12
        • 1970-01-01
        • 1970-01-01
        • 2012-06-02
        相关资源
        最近更新 更多