SelectedIndexProperty extends IntProperty implements ActionListener { public SelectedIndexProperty(@NotNull JComboBox comboBox) { myComboBox = comboBox; myComboBox.addActionListener(this); } SelectedIndexProperty(@NotNull JComboBox comboBox); @Override void actionPerformed(ActionEvent actionEvent); @NotNull @Override Integer get();  }
@Test public void testSelectedIndexProperty() { DefaultComboBoxModel model = new DefaultComboBoxModel(); model.addElement("A"); model.addElement("B"); model.addElement("C"); JComboBox comboBox = new JComboBox(model); SelectedIndexProperty selectedIndexProperty = new SelectedIndexProperty(comboBox); CountListener listener = new CountListener(); selectedIndexProperty.addListener(listener); assertThat(selectedIndexProperty.get()).isEqualTo(0); assertThat(listener.getCount()).isEqualTo(0); comboBox.setSelectedIndex(2); assertThat(selectedIndexProperty.get()).isEqualTo(2); assertThat(listener.getCount()).isEqualTo(1); selectedIndexProperty.set(1); assertThat(comboBox.getSelectedIndex()).isEqualTo(1); assertThat(listener.getCount()).isEqualTo(2); }