I have a GridPane
filled with 1-letter-labels.
Here is an image:
Here is the code:
int charSpacing = 1;
int charsInWid
GridPane.setHalignment(tmp[currArrPos], HPos.CENTER);
Using GridPane to layout controlsoh, that was easy. i did the alignment on the wrong place. adding this will do the job:
tmp[currArrPos].setAlignment(Pos.CENTER);
thanks anyway.
You can use the setAligment(Pos.CENTER)
property of your element-
or you can define a contraint
to the GridPane
that contains the elements
<columnConstraints>
<ColumnConstraints halignment="CENTER" />
</columnConstraints>
Example:
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.ColumnConstraints?>
<GridPane fx:controller="app.graphics.Controller"
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
<columnConstraints>
<ColumnConstraints halignment="CENTER" />
</columnConstraints>
</GridPane>