-
Bug
-
Resolution: Fixed
-
P4
-
8u40
-
8u40b9
See example below that demonstrates the issue which has the same reason as RT-15793 and is marked as temporarily fixed for comboBox as well.
/**
* - sanity: open popup and see it's empty (expected)
* - press button
* - open popup
* - expected: see added item
* - actual: empty
*/
public class Combo15793Regression extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
ComboBox box = new ComboBox();
Button button = new Button("set empty list and add item");
button.setOnAction(e -> {
box.setItems(FXCollections.observableArrayList());
box.getItems().add("Toto");
});
Parent root = new VBox(box, button);
primaryStage.setScene(new Scene(root));
primaryStage.setTitle(System.getProperty("java.version"));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Didn't try earlier versions to verify if it really worked for ComBox (the bug was reported against ListView), though the code looks like it should have:
// FIXME temporary fix forRT-15793. This will need to be
// properly fixed when time permits
if (getSkin() instanceof ComboBoxListViewSkin) {
ComboBoxListViewSkin<?> skin = (ComboBoxListViewSkin<?>) getSkin();
//----> technically missing: skin.updateComboBoxItems();
// which might have been added later than this hack
skin.updateListViewItems();
}
culprit is the missing update of skin's alias to comboBoxItems
public void updateListViewItems() {
...
// sets list items to old comboBox items
this.listViewItems = comboBoxItems;
listView.setItems(listViewItems);
....
}
/**
* - sanity: open popup and see it's empty (expected)
* - press button
* - open popup
* - expected: see added item
* - actual: empty
*/
public class Combo15793Regression extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
ComboBox box = new ComboBox();
Button button = new Button("set empty list and add item");
button.setOnAction(e -> {
box.setItems(FXCollections.observableArrayList());
box.getItems().add("Toto");
});
Parent root = new VBox(box, button);
primaryStage.setScene(new Scene(root));
primaryStage.setTitle(System.getProperty("java.version"));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Didn't try earlier versions to verify if it really worked for ComBox (the bug was reported against ListView), though the code looks like it should have:
// FIXME temporary fix for
// properly fixed when time permits
if (getSkin() instanceof ComboBoxListViewSkin) {
ComboBoxListViewSkin<?> skin = (ComboBoxListViewSkin<?>) getSkin();
//----> technically missing: skin.updateComboBoxItems();
// which might have been added later than this hack
skin.updateListViewItems();
}
culprit is the missing update of skin's alias to comboBoxItems
public void updateListViewItems() {
...
// sets list items to old comboBox items
this.listViewItems = comboBoxItems;
listView.setItems(listViewItems);
....
}