Open Source JavaFX Now!

JFXtras Core Logo

MigLayout

JFXtras has classes that enable the use of the well known MigLayout for node positioning and sizing. The approach is two fold:

  1. Insert a MigLayout node (which is bound to the layout manager); all its childeren are allowed to specify MigLayout contstraints.
  2. Specify MigLayout constraints as the layoutInfo property of the child-nodes using the MigNodeLayoutInfo class.
MigLayout {
     constraints: "fill"
     content: Text { content: "test"
         layoutInfo: MigNodeLayoutInfo {
             constraints: "center,grow"
         }
     }
 }  

In order to reduce the amount of boilerplate code, some utility methods are available in the MigLayout class reducing the example code to:

MigLayout {
     constraints: "fill"
     content: Text { content: "test"
         layoutInfo: nodeConstraints( "center,grow" )
     }
 }  

Or even further to:

MigLayout {
     constraints: "fill"
     content: migNode( Text { content: "test" }, "center,grow" }
 }  

It also is allowed to use MigLayout's constraint classes thus enabling compile time checking:

MigLayout {
     constraints: LC{}.fill()
     content: migNode( Text { content: "test" }, CC{}.center().grow() }
 }  

Look in the test directory for some example code. The controls skin in XCalendarPicker uses MigLayout.

Known issues

It is still undefined in JavaFX if a container should monitor changes in the min/pref/max size settings of its children and automatically do a relayout. MigLayout-in-JavaFX currently does not. So therefor it is required to call a requestLayout on the MigLayout or any node higher up to flush changes in the child nodes to the screen.
The debug feature of MigLayout is not working in JavaFX.


<< Back to JFXtras FrontPage
< Back to Layouts

0 Attachments 0 Attachments
1887 Views