ComboBox selection not reset to top of dropdown list (items) in javafx 2.2


Question

I have a Source ComboBox to populate source fields (25-30 items) shown below in first page

"A"

"B"

...

"Z"

I have selected last item from ComboBox as shown below

"Z"

and when traversing to the next page after saving, i need to make the source combo selection blank, so i have return the below code to reset the Source combobox to point to first item (to reset the display to start from top of dropdown list for user selection)

// my first value in source List is empty space - “”

                    sourceComboBox.setValue("");

even if you use below code snippets like

                    sourceComboBox.getSelectionModel().selectFirst(); 
                    sourceComboBox.getItems().clear();
                    sourceComboBox.getSelectionModel().clearAndSelect(0);

but when i click open the combobox dropdown it still shows dropdown display from bottom as shown below

...

"X"

"Y"

"Z"

I am unable to post images for representing combobox values, so has put in above examples.

This looks like a graphics bug to me or am I doing something wrong? I have seen similar issue reported in below question but no work around suggested so far Combobox clearing value issue

1
2
5/23/2017 11:48:11 AM

If you want to simply "reset" the combo box, I think all you have to do is set the value to null, like so:

sourceComboBox.setValue(null);
1
1/29/2014 4:29:15 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon