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();
}
}
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();
}
}
- relates to
-
JDK-8147833 Combobox: IOOBE when selecting null item (JDK-8093165 not resolved)
-
- Closed
-