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

Combobox: IOOBE when selecting null item

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8u60
    • 8u25
    • javafx
    • None

      With 8u11 combobox items could contain a null element which could be selected fine. This is commonly used to allow users to clear the selection. With 8u25 and 8u40 an attempt to select the null element from the dropdown results in an IOOBE. See test below.

      Steps:
      1. Select non-null item.
      2. Select null item (first in dropdown).

      The workaround for this seems to be quite elaborate: every such combobox would need a special not-null placeholder for the empty element.


      public class ComboBoxTest2 extends Application
      {
        public static void main(String[] args)
        {
          Application.launch(args);
        }

        @Override
        public void start(Stage primaryStage) throws Exception
        {
          ComboBox<String> comboBox = new ComboBox<>();
          comboBox.getItems().setAll(null, "1", "2", "3");
          
          VBox root = new VBox(20, comboBox);
          primaryStage.setScene(new Scene(root, 500, 200));
          primaryStage.show();
        }
      }

            jgiles Jonathan Giles
            wlehmann Werner Lehmann
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: