Class FWMonthSubComponent

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ChangeListener

public class FWMonthSubComponent extends FWAbstractFormSubComponent implements ChangeListener
An FWMonthSubComponent displays a spinner with a list of months that the user can choose from.

Its constructor takes the numbers of the first month and the last month that should be displayed and optionally the number of the month that should be preselected. The months that are displayed in the list can be changed at runtime using the updateMonthsInList function.

Whenever the user selects a month, a stateChanged event is fired. At any time, it is possible to query the currently selected month using getValue or to set the currently selected month using setValue.

Months are numbered from 1 to 12!

International month names will be obtained from the locale.

Author:
ckunze
See Also:
  • Constructor Details

    • FWMonthSubComponent

      public FWMonthSubComponent(int aMin, int aMax, FWObservable aObservable, Map<String,Object> aFormComponentParameterMap)
      Constructs a FWMonthSubComponent offering the months from aMin to aMax to choose from. The first month in the list will be selected by default. Months are numbered from 1 to 12.
      Parameters:
      aMin -
      aMax -
      aObservable -
      aFormComponentParameterMap -
    • FWMonthSubComponent

      public FWMonthSubComponent(int aMin, int aMax, int aDefault, boolean aIsEnabled, FWObservable aObservable, Map<String,Object> aFormComponentParameterMap)
      Parameters:
      aMin - Number (1-12) of the first month in the list.
      aMax - Number (1-12) of the last month in the list.
      aDefault - Number (1-12) of the month that will be selected initially.
      aIsEnabled -
      aObservable -
      aFormComponentParameterMap -
  • Method Details

    • getValue

      public String getValue()
      Specified by:
      getValue in class FWAbstractFormSubComponent
      Returns:
      the currently seected month (0-11)
    • setValue

      public void setValue(String aValue)
      Selects the combo box item that corresponds to the given month or the first item if the given month does not exist in the list.
      Specified by:
      setValue in class FWAbstractFormSubComponent
      Parameters:
      aValue - The month to be selected (1-12)
    • updateMonthsInList

      public void updateMonthsInList(int aMin, int aMax)
      Rebuilds the combo's list so it contains months from aMin to aMax. After that, the same month as before is selected. If the previously selected month is no longer in the list, the first or last month from the list will be selected.
      Parameters:
      aMin - First selectable month (1-12)
      aMax - Last selectable month (1-12)
    • setEnabled

      public void setEnabled(boolean aIsEnabled)
      Overrides:
      setEnabled in class FWAbstractFormSubComponent
    • stateChanged

      public void stateChanged(ChangeEvent e)
      Specified by:
      stateChanged in interface ChangeListener
    • getSelectedValueList

      public List<Object> getSelectedValueList()
      Specified by:
      getSelectedValueList in class FWAbstractFormSubComponent
      Returns:
      value of the implemented subcomponent