Fix arbitrator language selection prompt text

After selecting a language from the combobox, it would no longer
display the prompt text and instead would be blank.

As per the documentation
https://docs.oracle.com/javase/10/docs/api/javafx/scene/control/ComboBoxBase.html#promptTextProperty:
> Prompt text is not displayed in all circumstances, it is dependent
> upon the subclasses of ComboBoxBase to clarify when promptText will be
> shown.

Therefore, use a custom buttonCell on the combo box to display the
prompt text.
This commit is contained in:
Devin Bileck 2018-10-12 23:45:49 -07:00
parent cb42942d86
commit b1066d8fe1
No known key found for this signature in database
GPG Key ID: C86D829C2399D073

View File

@ -193,6 +193,17 @@ public class ArbitratorSelectionView extends ActivatableViewAndModel<GridPane, A
languageComboBox = FormBuilder.<String>addLabelComboBox(root, ++gridRow, "", 15).second;
languageComboBox.setPromptText(Res.get("shared.addLanguage"));
languageComboBox.setButtonCell(new ListCell<String>() {
@Override
protected void updateItem(final String item, boolean empty) {
super.updateItem(item, empty) ;
if (empty || item == null) {
setText(Res.get("shared.addLanguage"));
} else {
setText(LanguageUtil.getDisplayName(item));
}
}
});
languageComboBox.setConverter(new StringConverter<String>() {
@Override
public String toString(String code) {