Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8259562

ComboBox no longer renders item which isn't in the list

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows 7, also Redhat 8.2
      Both OpenJDK 11.0.9 and OpenJDK 14.0.1

      A DESCRIPTION OF THE PROBLEM :
      In Java 8 it was possible to display an item in the ComboBox "button cell" which wasn't one of the items in the list
      This functionality is mentioned in comments in javafx.scene.control.skin.ComboBoxListViewSkin.updateValue() suggesting it should be possible

      // RT-21336 Show the ComboBox value even though it doesn't
      // exist in the ComboBox items list (part one of fix)

      Now in Java 11 (and 14) the behaviour has changed, the ComboBox displays blank

      REGRESSION : Last worked in version 8

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the following. Press the button


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      "CHERRY" shown in ComboBox
      ACTUAL -
      ComboBox is blank

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.ComboBox;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class ComboBoxIssue extends Application {

          public enum Fruit {
              APPLE, BANANA, CHERRY
          }

          public static void main(String[] args) {
              launch(args);
          }

          @Override
          public void start(Stage primaryStage) throws Exception {
              ComboBox<Fruit> fruits = new ComboBox<>();
              fruits.getItems().addAll(Fruit.APPLE, Fruit.BANANA);
              fruits.setValue(Fruit.APPLE);
              Button button = new Button("Change");
              button.setOnAction(event -> {
                  fruits.setValue(Fruit.CHERRY);
              });
              primaryStage.setScene(new Scene(new VBox(fruits, button)));
              primaryStage.show();
          }

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None known

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pnarayanaswa Praveen Narayanaswamy
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: