Skip to content

Commit

Permalink
Fix arbitrator language selection prompt text
Browse files Browse the repository at this point in the history
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.
devinbileck committed Oct 13, 2018
1 parent cb42942 commit b1066d8
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -193,6 +193,17 @@ public void updateItem(final String item, boolean empty) {

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) {

0 comments on commit b1066d8

Please sign in to comment.