mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-22 14:42:37 +01:00
Fix prompt text disappearing after selection
After selecting an option 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:
parent
313971d7d8
commit
933b0b8277
1 changed files with 22 additions and 0 deletions
|
@ -426,6 +426,17 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
|
|||
|
||||
fiatCurrenciesComboBox = FormBuilder.<FiatCurrency>addLabelComboBox(root, ++gridRow).second;
|
||||
fiatCurrenciesComboBox.setPromptText(Res.get("setting.preferences.addFiat"));
|
||||
fiatCurrenciesComboBox.setButtonCell(new ListCell<FiatCurrency>() {
|
||||
@Override
|
||||
protected void updateItem(final FiatCurrency item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty || item == null) {
|
||||
setText(Res.get("setting.preferences.addFiat"));
|
||||
} else {
|
||||
setText(item.getNameAndCode());
|
||||
}
|
||||
}
|
||||
});
|
||||
fiatCurrenciesComboBox.setConverter(new StringConverter<FiatCurrency>() {
|
||||
@Override
|
||||
public String toString(FiatCurrency tradeCurrency) {
|
||||
|
@ -442,6 +453,17 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
|
|||
cryptoCurrenciesComboBox = labelComboBoxTuple2.second;
|
||||
GridPane.setColumnIndex(cryptoCurrenciesComboBox, 3);
|
||||
cryptoCurrenciesComboBox.setPromptText(Res.get("setting.preferences.addAltcoin"));
|
||||
cryptoCurrenciesComboBox.setButtonCell(new ListCell<CryptoCurrency>() {
|
||||
@Override
|
||||
protected void updateItem(final CryptoCurrency item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty || item == null) {
|
||||
setText(Res.get("setting.preferences.addAltcoin"));
|
||||
} else {
|
||||
setText(item.getNameAndCode());
|
||||
}
|
||||
}
|
||||
});
|
||||
cryptoCurrenciesComboBox.setConverter(new StringConverter<CryptoCurrency>() {
|
||||
@Override
|
||||
public String toString(CryptoCurrency tradeCurrency) {
|
||||
|
|
Loading…
Add table
Reference in a new issue