CheckComboBox documentation's bad example

Issue #830 new
Bradley Turek
created an issue

In the documentation of CheckComboBox the, otherwise helpful, example is written:

// and listen to the relevant events (e.g. when the selected indices or 
 // selected items change).
 checkComboBox.getCheckModel().getCheckedItems().addListener(new ListChangeListener<String>() {
     public void onChanged(ListChangeListener.Change<? extends String> c) {
         System.out.println(checkComboBox.getCheckModel().getSelectedItems());
     }
 });

The problem here is that getSelectedItems() is not a method.

The correct method is getCheckedItems().

I bring it up because it could prove blocking to new users.

It surely took me a not-so-quick minute to figure it out.

Comments (1)

  1. Bradley Turek reporter

    It might be helpful to add a simple

    while(c.next()) {
        //do something with changes here
    }
    

    because according to the documentation of ListChangeListener,

    Important: It's necessary to call next() method before calling any other method of Change. The same applies after calling reset(). The only methods that works at any time is getList().

  2. Log in to comment