VisibleProperty extends BoolProperty implements ComponentListener { public VisibleProperty(@NotNull JComponent component) { myComponent = component; myComponent.addComponentListener(this); } VisibleProperty(@NotNull JComponent component); @Override void componentResized(ComponentEvent componentEvent); @Override void componentMoved(ComponentEvent componentEvent); @Override void componentShown(ComponentEvent componentEvent); @Override void componentHidden(ComponentEvent componentEvent); @NotNull @Override Boolean get();  }
@Test public void testVisibleProperty() throws Exception { JLabel label = new JLabel(); VisibleProperty visibleProperty = new VisibleProperty(label); CountListener listener = new CountListener(); visibleProperty.addListener(listener); assertThat(visibleProperty.get()).isTrue(); assertThat(listener.getCount()).isEqualTo(0); label.setVisible(false); SwingUtilities.invokeAndWait(EmptyRunnable.INSTANCE); assertThat(visibleProperty.get()).isFalse(); assertThat(listener.getCount()).isEqualTo(1); visibleProperty.set(true); assertThat(label.isVisible()).isTrue(); assertThat(listener.getCount()).isGreaterThan(1); }