how to disable checkbox dynamically

Hi i created 3 checkbox dynamically and now i want if i select any two checckbox then thired checkbox will be disable automatically. Please tell me how i can do it.

this is my code …

@SuppressWarnings(“serial”)
private VerticalLayout createAdditionLayout() {
VerticalLayout layout = new VerticalLayout();
layout.setSizeFull();
layout.setSpacing(true);
layout.setMargin(true);

      ModelResponse  modelResponse = modelDesignerListenerFunctions.getModelList();

        if (modelResponse != null) {
            for (final ModelDetails model : modelResponse.getList()) {

                final CheckBox c = new CheckBox(model.getModelName());
                layout.addComponent(c);

                c.addValueChangeListener(new ValueChangeListener() {

                    @SuppressWarnings("deprecation")
                    @Override
                    public void valueChange(ValueChangeEvent event) {
                        Boolean b = (Boolean) event.getProperty()
                                .getValue();
                        if (b) {
                            listCheck.add(model.getModelName());
                            set.add(model.getModelId());
                            check++;
                        } else {
                            listCheck.remove(model.getModelName())
                            set.remove(model.getModelId());
                            check--;
                        }
                });
            }

Hi, pretty hard to say with that code snippet alone how you should do it, but practically you should call “thirdCheckbox.setEnabled(false)” in appropriate event listener (attached to first/second checkbox).

cheers,
matti