com.toedter.calendar

Class JMonthChooser

Implemented Interfaces:
ChangeListener, ItemListener

public class JMonthChooser
extends JPanel
implements ItemListener, ChangeListener

JMonthChooser is a bean for choosing a month.
Version:
$LastChangedRevision: 100 $, $LastChangedDate: 2006-06-04 14:36:06 +0200 (So, 04 Jun 2006) $
Author:
Kai Toedter

Field Summary

protected boolean
hasSpinner
true, if the month chooser has a spinner component

Constructor Summary

JMonthChooser()
Default JMonthChooser constructor.
JMonthChooser(boolean hasSpinner)
JMonthChooser constructor with month spinner parameter.

Method Summary

Component
getComboBox()
Returns the month chooser's comboBox text area (which allow the focus to be set to it).
Locale
getLocale()
Returns the locale.
int
getMonth()
Returns the month.
Component
getSpinner()
Returns the month chooser's comboBox bar (which allow the focus to be set to it).
boolean
hasSpinner()
Returns the type of spinner the month chooser is using.
void
initNames()
Initializes the locale specific month names.
void
itemStateChanged(ItemEvent e)
The ItemListener for the months.
static void
main(String[] s)
Creates a JFrame with a JMonthChooser inside and can be used for testing.
void
setDayChooser(JDayChooser dayChooser)
Convenience method set a day chooser.
void
setEnabled(boolean enabled)
Enable or disable the JMonthChooser.
void
setFont(Font font)
Sets the font for this component.
void
setLocale(Locale l)
Set the locale and initializes the new month names.
void
setMonth(int newMonth)
Sets the month.
void
setYearChooser(JYearChooser yearChooser)
Convenience method set a year chooser.
void
stateChanged(ChangeEvent e)
Is invoked if the state of the spnner changes.
void
updateUI()
Updates the UI.

Field Details

hasSpinner

protected boolean hasSpinner
true, if the month chooser has a spinner component

Constructor Details

JMonthChooser

public JMonthChooser()
Default JMonthChooser constructor.

JMonthChooser

public JMonthChooser(boolean hasSpinner)
JMonthChooser constructor with month spinner parameter.
Parameters:
hasSpinner - true, if the month chooser should have a spinner component

Method Details

getComboBox

public Component getComboBox()
Returns the month chooser's comboBox text area (which allow the focus to be set to it).
Returns:
the combo box

getLocale

public Locale getLocale()
Returns the locale.
Returns:
the locale value

getMonth

public int getMonth()
Returns the month.
Returns:
the month value

getSpinner

public Component getSpinner()
Returns the month chooser's comboBox bar (which allow the focus to be set to it).
Returns:
Component the spinner or null, if the month chooser has no spinner

hasSpinner

public boolean hasSpinner()
Returns the type of spinner the month chooser is using.
Returns:
true, if the month chooser has a spinner

initNames

public void initNames()
Initializes the locale specific month names.

itemStateChanged

public void itemStateChanged(ItemEvent e)
The ItemListener for the months.
Parameters:
e - the item event

main

public static void main(String[] s)
Creates a JFrame with a JMonthChooser inside and can be used for testing.
Parameters:
s - The command line arguments

setDayChooser

public void setDayChooser(JDayChooser dayChooser)
Convenience method set a day chooser.
Parameters:
dayChooser - the day chooser

setEnabled

public void setEnabled(boolean enabled)
Enable or disable the JMonthChooser.
Parameters:
enabled - the new enabled value

setFont

public void setFont(Font font)
Sets the font for this component.
Parameters:
font - the desired Font for this component

setLocale

public void setLocale(Locale l)
Set the locale and initializes the new month names.
Parameters:
l - the new locale value

setMonth

public void setMonth(int newMonth)
Sets the month. This is a bound property. Valuse are valid between 0 (January) and 11 (December). A value <320 will be treated as 0, a value > 11 will be treated as 11.
Parameters:
newMonth - the new month value

setYearChooser

public void setYearChooser(JYearChooser yearChooser)
Convenience method set a year chooser. If set, the spin for the month buttons will spin the year as well
Parameters:
yearChooser - the new yearChooser value

stateChanged

public void stateChanged(ChangeEvent e)
Is invoked if the state of the spnner changes.
Parameters:
e - the change event.

updateUI

public void updateUI()
Updates the UI.
See Also:
javax.swing.JPanel.updateUI()

Copyright B) 1999 - 2006 Kai Toedter.