Layouts and Resizable Containers are provided to handle Stage, Scene and Component resizing, maintaining logical positioning and sizing across the desired component range.
The following classes are available:
MigLayout - Use MigLayout to size and position nodes.
XGrid - Powerful and versatile Grid layout with a declarative syntax
XHBox & XVBox - HBox and VBox implementations that resize their contents
XScene - Drop-in replacement for Scene that will automaticlaly resize its children
XStack - Stack implementation that will propogate up JFXtras layout defaults
The JFXtras Default System
All of the JFXtras Controls are pre-configured with default layout options that will give you reasonable results when put directly in a layout container. For example, the JFXtras XPicker will fill horizontal and vertical, align left, and grow horizontally (sometimes). There are also defaults built-in for all the core JFXtras controls, so those will work together seamlessly.
This gives you the ability to layout forms or simple bordered layouts without worrying about setting up a lot of configuration.
Defaults will also propagate up the chain, trickling through parent contains, so you can safely nest your components in XStacks, XBoxes, or other layout containers without worrying about the defaults getting obscured.
Layout Constraints
All the JFXtras Layouts support a common set of layout constraints. These include the standard JavaFX LayoutInfo parameters, plus a set of additional extensions that are only supported by JFXtras layouts.
LayoutInfo Constraints (supported by all JavaFX Layouts):
Constraint
Type
Default
Description
hpos
HPos
CENTER
The horizontal alignment of the Node within its Cell
vpos
VPos
CENTER
The vertical alignment of the Node within its Cell
XLayoutInfo Constraints (supported by all JFXtras Layouts):
Constraint
Type
Default
Description
margin
Insets
insets(0)
Allows you to set a margin around the Node
hfill
Boolean
false
Whether or not the Node will fill available horizontal space within its Cell
vfill
Boolean
false
Whether or not the Node will fill available vertical space within its Cell
hgrow
Priority
NEVER
Whether or not the Node's Cell bounds will grow horizontally
vgrow
Priority
NEVER
Whether or not the Node's Cell bounds will grow vertically
hshrink
Priority
SOMETIMES
Whether or not the Node's Cell bounds will shrink horizontally
vshrink
Priority
SOMETIMES
Whether or not the Node's Cell bounds will shrink vertically
XGridLayoutInfo Constraints (supported by the JFXtras XGridLayout):
Constraint
Type
Default
Description
hspan
Integer
1
Number of cells that will be spanned horizontally
vspan
Integer
1
Number of cells that will be spanned vertically
Writing JFXtras Compatible Controls
All the usual best practices for writing JavaFX Controls applies, but if you do a few additional steps your control will also take advantage of the full power of the JFXtras Default System.
Steps:
Make sure your control extends DefaultLayout (in the org.jfxtras.scene.layout package)
Override or set the defaultLayoutInfo variable to an instance of XLayoutInfo
Set only the XLayoutInfo properties that you want to override
Example:
publicclass XPicker extends Control, DefaultLayout {overridevar defaultLayoutInfo = XLayoutInfo {
hfill: true
vfill: true
hgrow: SOMETIMES
hpos: LEFT
}}