Java Reference
In-Depth Information
the node children owned by the target grid pane to determine whether it is the specified
cell. Once the specified cell and child node is determined, the alignment is applied. The
following code shows an EventHandler that applies a cell constraint when the ap-
ply button is pressed:
cellApplyButton.setOnAction((ActionEvent event) -> {
for (Node child:targetGridPane.getChildren()) {
int targetColIndx = 0;
int targetRowIndx = 0;
try {
targetColIndx
= Integer.parseInt(cellColFld.getText());
targetRowIndx
= Integer.parseInt(cellRowFld.getText());
} catch (NumberFormatException e) {
}
System.out.println("child = "
+ child.getClass().getSimpleName());
int col = GridPane.getColumnIndex(child);
int row = GridPane.getRowIndex(child);
if (col == targetColIndx && row == targetRowIndx)
{
GridPane.setHalignment(child,
HPos.valueOf(hAlignFld.getSelectionModel().
getSelectedItem().toString()));
GridPane.setValignment(child,
VPos.valueOf(vAlignFld.getSelectionModel().
getSelectedItem().toString()));
}
}
});
Figure 15-8 depicts the cell constraint grid control panel section that left-aligns the
control at cell column 0 and cell row 2 .
Search WWH ::




Custom Search