EditableProperty extends BoolProperty implements PropertyChangeListener { public EditableProperty(JTextComponent textComponent) { myTextComponent = textComponent; myTextComponent.addPropertyChangeListener("editable", this); } EditableProperty(JTextComponent textComponent); @Override void propertyChange(PropertyChangeEvent propertyChangeEvent); @NotNull @Override Boolean get();  }
@Test public void testEditableProperty() { JTextField field = new JTextField(); EditableProperty editableProperty = new EditableProperty(field); CountListener listener = new CountListener(); editableProperty.addListener(listener); assertThat(editableProperty.get()).isTrue(); assertThat(listener.getCount()).isEqualTo(0); field.setEditable(false); assertThat(editableProperty.get()).isFalse(); assertThat(listener.getCount()).isEqualTo(1); editableProperty.set(true); assertThat(field.isEditable()).isTrue(); assertThat(listener.getCount()).isEqualTo(2); }