Created
March 29, 2019 04:50
-
-
Save seraphy/ddc7fd6feaa7d45046ef790913f02234 to your computer and use it in GitHub Desktop.
Java8のJavaFXのComboBoxでnullを要素にもつリストを選択するとIndexOutOfBoundsException例外が発生する例。(Java11のJavaFX11では修正されており、問題は発生しないことを確認。)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package jp.seraphyware.example.lava8learn.jfx; | |
| import javafx.application.Application; | |
| import javafx.collections.FXCollections; | |
| import javafx.collections.ObservableList; | |
| import javafx.scene.Scene; | |
| import javafx.scene.control.ComboBox; | |
| import javafx.scene.layout.VBox; | |
| import javafx.stage.Stage; | |
| /** | |
| * Java8のJavaFXのComboBoxでnullを要素にもつリストを選択すると | |
| * IndexOutOfBoundsException例外が発生する例。 | |
| * (Java11のJavaFX11では修正されており、問題は発生しないことを確認。) | |
| * | |
| * https://bugs.openjdk.java.net/browse/JDK-8134923 | |
| */ | |
| public class JFX8NullComboItemExample extends Application { | |
| private final ObservableList<String> items = FXCollections.observableArrayList(); | |
| @Override | |
| public void start(Stage stg) throws Exception { | |
| VBox box = new VBox(); | |
| ComboBox<String> combo = new ComboBox<>(items); | |
| combo.setPrefWidth(400); | |
| combo.setMaxWidth(Double.MAX_VALUE); | |
| box.getChildren().add(combo); | |
| stg.setScene(new Scene(box)); | |
| stg.show(); | |
| items.setAll(null, "a"); | |
| } | |
| public static void main(String[] args) { | |
| launch(args); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment