Package com.portal.app.comp
Class CurrencyWidgetsInitializer
java.lang.Object
com.portal.app.comp.CurrencyWidgetsInitializer
Initializes primary and secondary combo boxes controls. The expected use
is for a listener to be set on the primary currency widget. Then when
Additional convenience methods are also provided to do sets and look-ups.
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();
}
}
}
Additional convenience methods are also provided to do sets and look-ups.
-
Constructor Summary
ConstructorsConstructorDescriptionCurrencyWidgetsInitializer
(JComboBox primaryCurrencyCB, JComboBox secondaryCurrencyCB) Creates an initialzer for the passed-in primary and secondary currency combo boxes. -
Method Summary
Modifier and TypeMethodDescriptionint
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
Initialize the list of primary currencies depending on the default system locale.void
Initializes the list of secondary currencies associated with the currently-selected primary currency.void
Enables the secondary currency widget if there is more than one secondary currency; else disables it.
-
Constructor Details
-
CurrencyWidgetsInitializer
Creates an initialzer for the passed-in primary and secondary currency combo boxes.- Parameters:
primaryCurrencyCB
- Primary currency widgetsecondaryCurrencyCB
- Secondary currency widget
-
-
Method Details
-
selectPrimaryCurrency
public void selectPrimaryCurrency()Initialize the list of primary currencies depending on the default system locale. -
selectSecondaryCurrency
public void selectSecondaryCurrency()Initializes the list of secondary currencies associated with the currently-selected primary currency. Assumes that the primary currencies have been loaded into the primary currency combo box. -
setSecondaryCurrencyEnabledState
public void setSecondaryCurrencyEnabledState()Enables the secondary currency widget if there is more than one secondary currency; else disables it. -
getPrimaryCurrencyIndex
public int getPrimaryCurrencyIndex(int currencyID) Searches the list of primary currencies for the passed-in currency ID and returns the index of the matching entry.- Parameters:
currencyID
- Primary currency ID. Assumes that primary currencies have been loaded into the combo box.- Returns:
- index of entry containing
currencyID
or-1
if no matching entry is found.
-
getSecondaryCurrencyIndex
public int getSecondaryCurrencyIndex(int currencyID) Searches the list of secondary currencies for the passed-in currency ID and returns the index of the matching entry.- Parameters:
currencyID
- Secondary currency ID. Assumes that secondary currencies have been loaded into the combo box.- Returns:
- index of entry containing
currencyID
or-1
if no matching entry is found.
-
selectCurrencies
public void selectCurrencies(int newPrimary, int newSecondary) Sets the primary and secondary currencies. If the specified secondary currency isn't associated with the primary currency, only the primary currency is set. Assumes that both currencies have been loaded into their combo boxes.- Parameters:
newPrimary
- primary currency to switch to.newSecondary
- secondary currency to switch to.
-