javafx - ComboBox selected value not getting translated -
my app should have several languages. english default. problem if user switch different language, translated except combobox
selected value. how looks:
code behind combobox
is:
observablelist<currency> currencyitem= currencyda.getcurrencies(); currenciescombobox.setitems(currencyitem); callback<listview<currency>, listcell<currency>> currencyfactory = lv -> new listcell<currency>(){ @override protected void updateitem(currency currency, boolean empty){ super.updateitem(currency, empty); settext(empty ? "" : interfacebundle.getstring("currency_"+currency.getname())); } }; currenciescombobox.setcellfactory(currencyfactory); currenciescombobox.setbuttoncell(currencyfactory.call(null)); currenciescombobox.getselectionmodel().selectfirst();
how can selected value refreshed?
from doc
as combobox internally renders content listview, api exists in combobox class allow custom cell factory set. more information on cell factories, refer cell , listcell classes. it important note if cell factory set on combobox, cells used in listview shows when combobox clicked. if want customize rendering of 'button' area of combobox, can set custom listcell instance in button cell property. 1 way of doing following code :
//(note use of setbuttoncell): callback<listview<string>, listcell<string>> cellfactory = ...; combobox combobox = new combobox(); combobox.setitems(items); combobox.setbuttoncell(cellfactory.call(null)); combobox.setcellfactory(cellfactory);
so thing have add :
currenciescombobox.setbuttoncell(currencyfactory.call(null));
Comments
Post a Comment