JavaFX: Bringing Rich Experiences To All the Screens Of Your Life

Profile: desktop, common

Overview

This container uses a flexible Grid layout algorithm to position and size its children. Creating a new Grid is as easy as constructing an instance, adding in a list of Rows, and populating whatever Nodes you want to display.

Reasonable defaults are provided for most of the common JavaFX components, but for more control you can wrap Nodes in Cell objects and set various constraints such as grow, span, and preferred dimensions.

Here is a sample Grid to create a form:

 Grid {
     rows: [
         row([Text {content: "Username:"}, TextBox {}]),
         row([Text {content: "Password:"}, TextBox {}]),
         row([Cell {content: TextBox {}, hspan: 2}])
     ]
 }
 

For more information about using Grids, please refer to the test examples in the JavaFX source code, or see my blog: http://steveonjava.wordpress.com/

Variable Summary

accessnametypeCan ReadCan InitCan WriteDefault Valuedescription
publicborderNumber

The size of the border that will be placed around this Grid.

The size of the border that will be placed around this Grid. The border is both empty and transparent. Set this to 0 to remove the border.

 
publicgrowColumnsNumber[]

A decimal value between 0 and 1 that designates the percentage of space the column with the matching index will consume of any available space in the container.

A decimal value between 0 and 1 that designates the percentage of space the column with the matching index will consume of any available space in the container.

If the total amount of grow values exceeds 100% (1.0), then the whole area will be filled proportionally by percentage.

If the total amount of grow values is less than 100%, then the remaining amount will be empty.

 
publicgrowRowsNumber[]

A decimal value between 0 and 1 that designates the percentage of space the row with the matching index will consume of any available space in the container.

A decimal value between 0 and 1 that designates the percentage of space the row with the matching index will consume of any available space in the container.

If the total amount of grow values exceeds 100% (1.0), then the whole area will be filled proportionally by percentage.

If the total amount of grow values is less than 100%, then the remaining amount will be empty.

 
publichgapNumber

The width of the horizontal gaps between cells.

The width of the horizontal gaps between cells. This can be set to zero to have cells flush against each other.

 
publicrowsRow[]
publicvgapNumber

The width of the vertical gaps between cells.

The width of the vertical gaps between cells. This can be set to zero to have cells flush against each other.

 

Inherited Variables

Function Summary

public requestLayout() : Void

Should be called if there are any changes to the contents that would require the Grid size to be recalculated.

Should be called if there are any changes to the contents that would require the Grid size to be recalculated.

 

Inherited Functions