On Mon, 1 Jun 2026 01:43:45 GMT, Christopher Schnick <[email protected]> 
wrote:

> This is a much simpler fix for JDK-8384806 which does not have any side 
> effects.
> 
> This restores the old code with only a one line change instead. For 
> reference, see 
> https://github.com/openjdk/jfx/commit/8d917ae738120e12ac12cd0957879b7c00e59b03.
>  We now fix the issue by clearing the cell with `buttonCell.updateIndex(-1);` 
> as using `buttonCell.setItem(null);` was causing the original issue when the 
> item was already null.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

The code that sets the list index to -1 is already a hack, and only really 
works for cells that haven't been modified (especially the updateDisplayNode 
part). This part just hard assumes the cell is a plain text label:

                // JDK-8127575 Show the ComboBox value even though it doesn't
                // exist in the ComboBox items list (part two of fix)
                buttonCell.updateIndex(-1);
                boolean empty = updateDisplayText(buttonCell, value, false);
                
Some ComboBoxes do customize their cell display (adding additional things like 
tags/descriptions or a small image) and updating just the text (and not all the 
other stuff it may have) therefore is going to give you a cell that doesn't 
behave like your customized cell at all.

This issue details the problem: https://bugs.openjdk.org/browse/JDK-8221722

-------------

PR Comment: https://git.openjdk.org/jfx/pull/2179#issuecomment-4615246830

Reply via email to