-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8, 9
-
x86_64
-
windows_7
FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows 7 64-bit
A DESCRIPTION OF THE PROBLEM :
In Java 1.8u60 the following four methods were added for the ChoiceBox: setOnShown, setOnShowing, setOnHidden, setOnHiding. But I cannot get them working. (See the code from Steps to Reproduce section)
For the ComboBox both setOnShown and setOnShowing methods work just fine, but for the ChoiceBox console output is empty except for selectedIndexProperty listener.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
public class ComboBoxSample extends Application {
public static void main(String[] args) {
launch(args);
}
@Override public void start(Stage stage) {
stage.setTitle("ComboBoxSample");
Scene scene = new Scene(new Group(), 450, 250);
final ComboBox<String> comboBox = new ComboBox<>();
comboBox.getItems().addAll(
"jacob.smith@example.com",
"isabella.johnson@example.com"
);
comboBox.setOnShown(event -> {
System.out.println("ComboBox onShown");
System.out.println(comboBox.getSelectionModel().getSelectedIndex());
});
comboBox.setOnShowing(event -> {
System.out.println("ComboBox setOnShowing");
System.out.println(comboBox.getSelectionModel().getSelectedIndex());
});
ChoiceBox<String> choiceBox = new ChoiceBox<>();
choiceBox.setItems(FXCollections.observableArrayList(
"New Document", "Open ")
);
choiceBox.setOnShown(event -> {
System.out.println("ChoiceBox onShown");
System.out.println(choiceBox.getSelectionModel().getSelectedIndex());
});
choiceBox.setOnShowing(event -> {
System.out.println("ChoiceBox onShowing");
System.out.println(choiceBox.getSelectionModel().getSelectedIndex());
});
choiceBox.setOnHidden(event -> {
System.out.println("ChoiceBox setOnHidden");
System.out.println(choiceBox.getSelectionModel().getSelectedIndex());
});
choiceBox.getSelectionModel().selectedIndexProperty().addListener(e -> {
System.out.println("ChoiceBox selectedIndexProperty");
});
GridPane grid = new GridPane();
grid.setVgap(4);
grid.setHgap(10);
grid.setPadding(new Insets(5, 5, 5, 5));
grid.add(new Label("ComboBox: "), 0, 0);
grid.add(comboBox, 1, 0);
grid.add(new Label("ChoiceBox: "), 0, 1);
grid.add(choiceBox, 1, 1);
Group root = (Group)scene.getRoot();
root.getChildren().add(grid);
stage.setScene(scene);
stage.show();
}
}
REPRODUCIBILITY :
This bug can be reproduced always.
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows 7 64-bit
A DESCRIPTION OF THE PROBLEM :
In Java 1.8u60 the following four methods were added for the ChoiceBox: setOnShown, setOnShowing, setOnHidden, setOnHiding. But I cannot get them working. (See the code from Steps to Reproduce section)
For the ComboBox both setOnShown and setOnShowing methods work just fine, but for the ChoiceBox console output is empty except for selectedIndexProperty listener.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
public class ComboBoxSample extends Application {
public static void main(String[] args) {
launch(args);
}
@Override public void start(Stage stage) {
stage.setTitle("ComboBoxSample");
Scene scene = new Scene(new Group(), 450, 250);
final ComboBox<String> comboBox = new ComboBox<>();
comboBox.getItems().addAll(
"jacob.smith@example.com",
"isabella.johnson@example.com"
);
comboBox.setOnShown(event -> {
System.out.println("ComboBox onShown");
System.out.println(comboBox.getSelectionModel().getSelectedIndex());
});
comboBox.setOnShowing(event -> {
System.out.println("ComboBox setOnShowing");
System.out.println(comboBox.getSelectionModel().getSelectedIndex());
});
ChoiceBox<String> choiceBox = new ChoiceBox<>();
choiceBox.setItems(FXCollections.observableArrayList(
"New Document", "Open ")
);
choiceBox.setOnShown(event -> {
System.out.println("ChoiceBox onShown");
System.out.println(choiceBox.getSelectionModel().getSelectedIndex());
});
choiceBox.setOnShowing(event -> {
System.out.println("ChoiceBox onShowing");
System.out.println(choiceBox.getSelectionModel().getSelectedIndex());
});
choiceBox.setOnHidden(event -> {
System.out.println("ChoiceBox setOnHidden");
System.out.println(choiceBox.getSelectionModel().getSelectedIndex());
});
choiceBox.getSelectionModel().selectedIndexProperty().addListener(e -> {
System.out.println("ChoiceBox selectedIndexProperty");
});
GridPane grid = new GridPane();
grid.setVgap(4);
grid.setHgap(10);
grid.setPadding(new Insets(5, 5, 5, 5));
grid.add(new Label("ComboBox: "), 0, 0);
grid.add(comboBox, 1, 0);
grid.add(new Label("ChoiceBox: "), 0, 1);
grid.add(choiceBox, 1, 1);
Group root = (Group)scene.getRoot();
root.getChildren().add(grid);
stage.setScene(scene);
stage.show();
}
}
REPRODUCIBILITY :
This bug can be reproduced always.
- duplicates
-
JDK-8175963 ChoiceBox using events from ComboBox
-
- Resolved
-