private void createRadioButtons ( ) { node . getChildren ( ) . clear ( ) ; radioButtons . clear ( ) ; for ( int i = 0 ; i < field . getItems ( ) . size ( ) ; i ++ ) { RadioButton rb = new RadioButton ( ) ; rb . setText ( field . getItems ( ) . get ( i ) . toString ( ) ) ; rb . setToggleGroup ( toggleGroup ) ; radioButtons . add ( rb ) ; } if ( field . getSelection ( ) != null ) { radioButtons . get ( field . getItems ( ) . indexOf ( field . getSelection ( ) ) ) . setSelected ( true ) ; } node . getChildren ( ) . addAll ( radioButtons ) ; }
This method creates radio buttons and adds them to radioButtons and is used when the itemsProperty on the field changes .