Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFx GridPane layout how to set margin for an element in row?

I'm using GridPane layout for positioning things in my application. I'm wondering how I can set margin for an element in row

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

Is it possible in GridPane?

like image 644
krychuq Avatar asked Sep 17 '15 15:09

krychuq


2 Answers

You can set the margin for any particular Node:

GridPane.setMargin(chip5, new Insets(5, 0, 0, 0));
like image 124
James_D Avatar answered Nov 20 '22 21:11

James_D


In FXML, you can do it as follows:

<TextField fx:id="txtFirstName" GridPane.rowIndex="0" GridPane.columnIndex="1">
    <GridPane.margin>
        <Insets right="30"/>
    </GridPane.margin>
</TextField>
like image 5
Eng.Fouad Avatar answered Nov 20 '22 23:11

Eng.Fouad