I'm trying to make a TableCell for the ever-so-handy CheckComboBox
.
I've taken and adapted the original ComboBoxTableCell
and CellUtils
implementations.
Can you help me figure out what I'm doing wrong?
- Changed all
ComboBox
toCheckComboBox
- Commented out some things that deal with selection;
CheckComboBox
doesn't use aSelectionModel
it uses aCheckModel
. - Commented out some things that deal with editability; 'ppurrently
CheckComboBox
doesn't believe in such things, either. - Only committing the change once the user closes the combo box instead of after the first selection.
- Used
column.addEventHandler(TableColumn.editCommitEvent(), event -> {/*Do stuff here*/});
instead of.setOnEditCommit
to preserve the default property write back (seeTableView
Documentation) - Transferring checks from one
TableCell
to another in theupdateItem
method
When ever the rows move around, they lose their value (I know this has to do with theupdateItem
method, but I can't figure out which part of it isn't working as intended)- Problem: I was using the
column.setOnEditCommit()
and as the documentation states in the Editing section, java then assumes you'll put yourself in charge of writing the committed value back to the property. - Solution: To observe commit events, without affecting their being written back to the underlying property, I instead use,
column.addEventHandler(TableColumn.editCommitEvent(), event -> {/*Do stuff here*/});
- Problem: I was using the
- I can't pass in a
StringConverter
that works; so for now I'm doing this conversion a different way. I would, however, like to do it with a converter. - In my POJO, to represent the checked items in the
CheckComboBox
, I wanted to be able to use aListProperty<String>
, but the original implementation ofComboBoxTableCell
seems to favor aStringProperty
. - When you click from the
CheckComboBox
to the same cell you get this exception (which looks a lot like this one). It renders the cell useless. Here's an animation of how to replicate it.
I really do want to figure this out, so I went through the trouble of making a Minimal Complete Verifiable Example.
It will save you a lot of work and guessing—it will help you help me, so please download and run it.