On Mon, 11 May 2026 17:18:28 GMT, Marius Hanl <[email protected]> wrote:

>> Christopher Schnick has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Update tests
>
> modules/javafx.controls/src/main/java/javafx/scene/control/skin/ComboBoxListViewSkin.java
>  line 182:
> 
>> 180:         });
>> 181:         lh.addChangeListener(control.converterProperty(), e -> {
>> 182:             updateCellFactory();
> 
> Here, I wonder if we just can call `listView.refresh()`. Because we 
> effectively want all cells to 'recalculate' their value.
> 
> And there is one problem now with the current approach: If we have custom 
> `cellFactory` that uses the `converter`, it won't get updated. 
> 
> Because in `updateCellFactory()` the `cellFactory` is the same as before, so 
> will be a noop and the `ListView` items will not change.
> 
> <details>
> <summary>Reproducer</summary>
> 
> 
> import javafx.application.Application;
> import javafx.collections.FXCollections;
> import javafx.collections.ObservableList;
> import javafx.scene.Scene;
> import javafx.scene.control.Button;
> import javafx.scene.control.ComboBox;
> import javafx.scene.control.ListCell;
> import javafx.scene.layout.BorderPane;
> import javafx.stage.Stage;
> import javafx.util.StringConverter;
> 
> public class ComboBoxCustomListCell extends Application {
> 
>     private final ObservableList<String> strings = 
> FXCollections.observableArrayList("Option 1", "Option 2",
>             "Option 3");
> 
>     public static void main(String[] args) {
>         launch(args);
>     }
> 
>     @Override
>     public void start(Stage stage) {
>         final ComboBox<String> comboBox = new ComboBox<>();
>         comboBox.setConverter(new StringConverter<>() {
>             @Override
>             public String toString(String object) {
>                 return "CONVERTER: " + object;
>             }
> 
>             @Override
>             public String fromString(String string) {
>                 return null;
>             }
>         });
>         comboBox.setItems(FXCollections.observableArrayList(strings));
>         comboBox.setCellFactory(_ -> new ListCell<>() {
>             @Override
>             public void updateItem(String item, boolean empty) {
>                 super.updateItem(item, empty);
> 
>                 if (empty || item == null) {
>                     setText(null);
>                 } else {
>                     setText(comboBox.getConverter().toString(item));
>                 }
>             }
>         });
> 
>         BorderPane root = new BorderPane(comboBox);
>         Button value = new Button("Change Converter");
>         value.setOnAction(event -> {
>             comboBox.setConverter(new StringConverter<>() {
>                 @Override
>                 public String toString(String ob...

That is a good point, I updated the PR.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/2165#discussion_r3221032710

Reply via email to