SelectedProperty extends BoolProperty implements ItemListener { public SelectedProperty(@NotNull AbstractButton button) { myButton = button; myButton.addItemListener(this); } SelectedProperty(@NotNull AbstractButton button); @Override void itemStateChanged(ItemEvent itemEvent); @NotNull @Override Boolean get();  }
@Test public void testSelectedProperty() { JCheckBox checkbox = new JCheckBox(); checkbox.setSelected(true); SelectedProperty selectedProperty = new SelectedProperty(checkbox); CountListener listener = new CountListener(); selectedProperty.addListener(listener); assertThat(selectedProperty.get()).isTrue(); assertThat(listener.getCount()).isEqualTo(0); checkbox.setSelected(false); assertThat(selectedProperty.get()).isFalse(); assertThat(listener.getCount()).isEqualTo(1); selectedProperty.set(true); assertThat(checkbox.isSelected()).isTrue(); assertThat(listener.getCount()).isEqualTo(2); }