如何在 vaadin 8 的复选框组中为一个特定的复选框设置 css 样式

how to put css styling for one specific checkbox in checkboxGroup of vaadin 8

我有一个包含多个复选框的复选框组。我有一些复选框需要看起来不同,无论是粗体文本还是彩色文本,无论selection/unselection如何,它们都不会改变。 我有以下代码来构建复选框组。但是我无法将特定于一个复选框的样式放入其中,因为我无权访问它。我该怎么做

CheckBoxGroup<ReferenceScreenResultAnswer> answersOptionGroup = new CheckBoxGroup<>(question.getText());
List<ReferenceScreenResultAnswer> checkBoxItems = new ArrayList<>();
answersOptionGroup.setItems(checkBoxItems);
.......
// this is where i want to put CSS to specific checkbox/values
for (Answer answer : preSelectedAnswer)
{
    ReferenceScreenResultAnswer rsra = new ReferenceScreenResultAnswer();
    rsra.setAnswer(answer);
    rsra.setReferenceScreenResultQuestion(rsrq);
    answersOptionGroup.select(rsra);
}

我可以像

那样做单独的复选框
CheckBox cb = new CheckBox();
cb.setCaptionAsHtml(true);
cb.setCaption("<b> hello </b> there");

但我无法从 CheckBoxGroup 访问单个复选框。知道如何访问它们

我找到了答案:

                    // css style the pre selected answer, so they look different irrespective
                    // of their selection
                    answersOptionGroup.setItemCaptionGenerator(new ItemCaptionGenerator<ReferenceScreenResultAnswer>()
                    {
                        @Override
                        public String apply(ReferenceScreenResultAnswer item)
                        {       
                            if (preSelectedAnswer.contains(item.getAnswer()))
                                return "<strong>" + item.getAnswer().toString() + "</strong>";
                            else
                                return item.getAnswer().toString();
                        }
                    });