Menu:

12-Mar-2008 Latest component update.

MonthBox

component iconJMonthBox is a month selection component combining a combo box and a rolling spinner (i.e. after the last item it rolls back to the first and vice versa). The month names can be either those associated with a locale or custom month names. The JPopupButton class extends the Swing JSpinner component.

month boxes for different locales
The month box component in two different locales

Creation

public JMonthBox()
public JMonthBox(String[] months)
public JMonthBox(Locale locale)

The default constructor creates a month box with the month names of the current locale. The second constructor accepts 12 custom month names, while the third constructor uses the month names of the specified locale.

Methods

public String getSelectedMonth()
public int getSelectedMonthNumber()
public int getSelectedIndex()
public void setSelectedMonthNumber(int number)

In these accessors the selected month number has a value from 1-12, while the selected index has values from 0-11.

Events

public void addMonthChangeListener(ChangeListener l)
public void removeMonthChangeListener(ChangeListener l)

Get a notification for a value change by adding a ChangeListener to the JMonthBox object. The generated ChangeEvent has this JMonthBox object as the source.