public class CurrencyWidgetsInitializer extends Object
selectPrimaryCurrency
is called to initialize the primary
currency combo box or whenever the user subsequently selects a new
primary currency, the secondary currency widget can be initialized by a
call to selectSecondaryCurrency
.
For example,
public void itemStateChanged(java.awt.event.ItemEvent event) {
Object object = event.getSource();
if (event.getStateChange() == ItemEvent.SELECTED) {
if (object == mPrimaryCurrencyCB) {
mCurrencyWidgetsInitializer.selectSecondaryCurrency();
}
}
}
Constructor and Description |
---|
CurrencyWidgetsInitializer(JComboBox primaryCurrencyCB,
JComboBox secondaryCurrencyCB)
Creates an initialzer for the passed-in primary and secondary currency
combo boxes.
|
Modifier and Type | Method and Description |
---|---|
int |
getPrimaryCurrencyIndex(int currencyID)
Searches the list of primary currencies for the passed-in
currency ID and returns the index of the matching entry.
|
int |
getSecondaryCurrencyIndex(int currencyID)
Searches the list of secondary currencies for the passed-in
currency ID and returns the index of the matching entry.
|
void |
selectCurrencies(int newPrimary,
int newSecondary)
Sets the primary and secondary currencies.
|
void |
selectPrimaryCurrency()
Initialize the list of primary currencies depending on the default
system locale.
|
void |
selectSecondaryCurrency()
Initializes the list of secondary currencies associated with the
currently-selected primary currency.
|
void |
setSecondaryCurrencyEnabledState()
Enables the secondary currency widget if there is more
than one secondary currency; else disables it.
|
public CurrencyWidgetsInitializer(JComboBox primaryCurrencyCB, JComboBox secondaryCurrencyCB)
primaryCurrencyCB
- Primary currency widgetsecondaryCurrencyCB
- Secondary currency widgetpublic void selectPrimaryCurrency()
public void selectSecondaryCurrency()
public void setSecondaryCurrencyEnabledState()
public int getPrimaryCurrencyIndex(int currencyID)
currencyID
- Primary currency ID. Assumes that primary
currencies have been loaded into the combo box.currencyID
or
-1
if no matching entry is found.public int getSecondaryCurrencyIndex(int currencyID)
currencyID
- Secondary currency ID. Assumes that secondary
currencies have been loaded into the combo box.currencyID
or
-1
if no matching entry is found.public void selectCurrencies(int newPrimary, int newSecondary)
newPrimary
- primary currency to switch to.newSecondary
- secondary currency to switch to.Copyright © 2003, 2023, Oracle and/or its affiliates.