public void layoutParts ( ) { StringBuilder styleClass = new StringBuilder ( "group" ) ; // if there are no rows yet, getRowCount returns -1, in this case the next row is 0 int nextRow = PreferencesFxUtils . getRowCount ( grid ) + 1 ; // Only when the preferencesGroup has a title if ( preferencesGroup . getTitle ( ) != null ) { grid . add ( titleLabel , 0 , nextRow ++ , 2 , 1 ) ; styleClass . append ( "-title" ) ; titleLabel . getStyleClass ( ) . add ( "group-title" ) ; } List < Field > fields = preferencesGroup . getElements ( ) . stream ( ) . map ( Field . class :: cast ) . collect ( Collectors . toList ( ) ) ; styleClass . append ( "-setting" ) ; int rowAmount = nextRow ; for ( int i = 0 ; i < fields . size ( ) ; i ++ ) { // add to GridPane Field field = fields . get ( i ) ; SimpleControl c = ( SimpleControl ) field . getRenderer ( ) ; c . setField ( field ) ; grid . add ( c . getFieldLabel ( ) , 0 , i + rowAmount , 1 , 1 ) ; grid . add ( c . getNode ( ) , 1 , i + rowAmount , 1 , 1 ) ; // Styling GridPane . setHgrow ( c . getNode ( ) , Priority . SOMETIMES ) ; GridPane . setValignment ( c . getNode ( ) , VPos . CENTER ) ; GridPane . setValignment ( c . getFieldLabel ( ) , VPos . CENTER ) ; // additional styling for the last setting if ( i == fields . size ( ) - 1 ) { styleClass . append ( "-last" ) ; GridPane . setMargin ( c . getNode ( ) , new Insets ( 0 , 0 , PreferencesFxFormRenderer . SPACING * 4 , 0 ) ) ; GridPane . setMargin ( c . getFieldLabel ( ) , new Insets ( 0 , 0 , PreferencesFxFormRenderer . SPACING * 4 , 0 ) ) ; } c . getFieldLabel ( ) . getStyleClass ( ) . add ( styleClass . toString ( ) + "-label" ) ; c . getNode ( ) . getStyleClass ( ) . add ( styleClass . toString ( ) + "-node" ) ; } }
Defines the layout of the rendered group .