@Test public void testAddChangeListener() throws IOException { final CC vv = new CC(); ComboBox<String> cb = new ComboBox<>(null); cb.addChangeListener(e -> { System.out.printf(" event %s %s %d [", e.getActionCommand(), cb.getSelectedItem(), cb.getSelectedIndex()); for (int i = 0; i < cb.getItemCount(); i++) { System.out.printf("%s,", cb.getItemAt(i)); } System.out.printf("]%n"); cb.addItem((String) cb.getSelectedItem()); System.out.printf(" -> addItem %s %d [", cb.getSelectedItem(), cb.getSelectedIndex()); for (int i = 0; i < cb.getItemCount(); i++) { System.out.printf("%s,", cb.getItemAt(i)); } System.out.printf("]%n"); vv.wascalled++; }); assertThat(vv.wascalled).isEqualTo(0); cb.addItem("first"); assertThat(cb.getSelectedItem()).isEqualTo("first"); cb.addItem("second"); assertThat(cb.getSelectedItem()).isEqualTo("second"); assertThat(vv.wascalled).isEqualTo(2); assertThat(cb.getSelectedIndex()).isEqualTo(0); System.out.printf("-----setSelectedItem(first)%n"); cb.setSelectedItem("first"); assertThat(cb.getSelectedItem()).isEqualTo("first"); assertThat(vv.wascalled).isEqualTo(3); System.out.printf("-----addItem(third)%n"); cb.addItem("third"); assertThat(vv.wascalled).isEqualTo(4); }
public void addChangeListener(ActionListener successListener) { addActionListener(new ActionListenerAdapter("comboBoxChanged", successListener)); }
ComboBox extends JComboBox<E> { public void addChangeListener(ActionListener successListener) { addActionListener(new ActionListenerAdapter("comboBoxChanged", successListener)); } }
ComboBox extends JComboBox<E> { public void addChangeListener(ActionListener successListener) { addActionListener(new ActionListenerAdapter("comboBoxChanged", successListener)); } ComboBox();  ComboBox(PersistenceManager prefs);  ComboBox(PersistenceManager prefs, int nkeep); }
ComboBox extends JComboBox<E> { public void addChangeListener(ActionListener successListener) { addActionListener(new ActionListenerAdapter("comboBoxChanged", successListener)); } ComboBox();  ComboBox(PersistenceManager prefs);  ComboBox(PersistenceManager prefs, int nkeep); void addChangeListener(ActionListener successListener); void setPreferences(PersistenceManager prefs); JComponent getDeepEditComponent(); void addItem(E item); void save(); List<E> getItemList(); void setItemList(Collection<E> list); void setNkeep(int nkeep); int getNkeep(); }
ComboBox extends JComboBox<E> { public void addChangeListener(ActionListener successListener) { addActionListener(new ActionListenerAdapter("comboBoxChanged", successListener)); } ComboBox();  ComboBox(PersistenceManager prefs);  ComboBox(PersistenceManager prefs, int nkeep); void addChangeListener(ActionListener successListener); void setPreferences(PersistenceManager prefs); JComponent getDeepEditComponent(); void addItem(E item); void save(); List<E> getItemList(); void setItemList(Collection<E> list); void setNkeep(int nkeep); int getNkeep();  }