[REVIEW] Restricting the ComboBox selection model to single selection

Jonathan Giles jonathan.giles at oracle.com
Fri Feb 3 16:18:16 PST 2012


Hi all,

http://javafx-jira.kenai.com/browse/RT-19367

I'm asking for approval to change the API of the ComboBox selectionModel 
property, from the more general SelectionModel class, to the more 
specific SingleSelectionModel class. This enforces the fact that the 
ComboBox, for now and evermore, will only support single selection (much 
like the ChoiceBox control). Should multiple selection ever be needed, a 
separate 'ListBox' control can be developed to more aptly serve these needs.

The desire to make this change is, however, more due to the fact that 
the current API does no one any favours. It misleads developers to think 
that by installing a MultipleSelectionModel into the property, they may 
be afforded some multiple selection functionality, which is not true. 
This change makes it impossible for them to think this, as compilation 
will fail in this case. I would argue that this is a bug in the API, and 
one that should be fixed prior to being set in stone. Not fixing this 
bug prior to shipping the ComboBox control will lead to confusion and / 
or bug reports from developers expecting functionality.

The proposed patch is attached to the Jira issue. The changes are 
minimal and, I would argue, as risk free as one can hope. It has no 
impact on unit tests as there were no multiple selection tests written, 
and I hope the same can be said for the automated tests.

Thanks,
Jonathan


More information about the openjfx-dev mailing list