radiobuttongroup display custom Strings as options

I have a single-select radiobuttongroup with a boolean field behind it in the DataClass.

I don’t want to display “true” / “false” as options for the user, but custom Strings, let’s say “red option” for true and “green option” for false.

I see in the API that there is a function called setRenderer, but I am not sure how to use it.
I already figured out how to do it in a grid, but not on the selection box…

Selection box:

rbgroup = new RadioButtonGroup<>();
rbgroup.setLabel("Title of radiobuttongroup");
rbgroup.setItems(true, false); // how to display them in the frontend as "Green option" / "Red option"?




addColumn((mn) -> { // custom display
            final String displayAS;
            if (mn.getBoolValue()) {
                displayAS = "Option Red";
            } else {
                displayAS = "Option Green";
            return displayAS;
.setKey("Color Option");

I answered this same question on stackoverflow:

Best Regards

Thanks, I saw it :smiley: I wasn’t sure where I would get faster results :wink: