set Column Horizontal Grow in JavaFX GridPane - Java JavaFX

Java examples for JavaFX:GridPane

Description

set Column Horizontal Grow in JavaFX GridPane

Demo Code


//package com.java2s;

import javafx.scene.Node;

import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;

public class Main {
    public static void setColumnHGrow(GridPane pane, int col, Priority rule) {
        for (Node child : pane.getChildren()) {
            int colIndex = GridPane.getColumnIndex(child);
            int colSpan = GridPane.getColumnSpan(child);
            if (col >= colIndex && col < (colIndex + colSpan)) {
                GridPane.setHgrow(child, rule);
            }// w w w . j av  a 2  s  .  c  o  m
        }
    }
}

Related Tutorials