Brett Spell wrote:If I understand your code and comments correctly, it looks like your combo box-based editor is being used to select a PickListEntry value for a table cell, and it looks like PickListEntry potentially contains a reference to a color that you're using for the combo box popup list background and you also want to use for the table cell when it's not being edited.
Assuming that your code is already saving the selected PickListEntry correctly, that means that it's being saved in your table model, which in turn means that when the table goes to render the non-edited cells that your table cell renderer will also (like the combo box's list cell renderer) be passed an instance of PickListEntry. In that case, you just need to create a TableCellEditor implementation that does essentially the same as your ListCellRenderer: cast the value to be rendered to a PickListEntry, retrieve the color (if any) from it, and set the renderer component's background to that color.
Jason Richard wrote:Does that make sense?
Brett Spell wrote:
Jason Richard wrote:Does that make sense?
Frankly, no.
Well, ok, maybe a little. Let's see if I understood you correctly: you have a mapping from the PickListEntry to a corresponding String and it's that String value and not the PickListEntry that you're storing in your TableModel when a selection / edit occurs; is that right?
Brett Spell wrote:It sounds like all you need is to be able to perform a reverse lookup: given a String from the table model you want to be able to get to the corresponding PickListEntry that was selected via the JList-based editor. Based on your comment that you "do not have the ability to change this" I'm assuming that you can't modify the TableModel or the class(es) that maintain the set of PickListEntry objects, because those would have been my first choices for where to suggest adding the reverse lookup method. If neither of those is an option then I'd suggest creating a singleton that maintains the String-to-PickListEntry mapping with a couple of methods like this: