Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get width / height of a GridPane column / row?

While it's obvious how to set the width/height of a column/row in a GridPane, how can I actually query these values?

like image 782
stefan.at.wpf Avatar asked Nov 02 '22 23:11

stefan.at.wpf


1 Answers

JavaFX8: There is a pack protected method GridPane.getGrid to get the current row/col sizes in a two dim double array.You could use reflection to acccess it. In environments with a security mgr, this won't work.

public double[][] getCurrentGrid(GridPane gp) {
    double[][] ret=new double [0][0];

    try {
        Method m=gp.getClass().getDeclaredMethod("getGrid");
        m.setAccessible(true);
        ret=(double[][])m.invoke(gp);                   

    } catch (Exception e) {
        e.printStackTrace();
    }

    return ret;
}
like image 72
bernhard Avatar answered Nov 13 '22 21:11

bernhard