Class JMonthChooser

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

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
See Also:
  • Field Details

  • 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

    • initNames

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

      public void stateChanged(ChangeEvent e)
      Is invoked if the state of the spnner changes.
      Specified by:
      stateChanged in interface ChangeListener
      Parameters:
      e - the change event.
    • itemStateChanged

      public void itemStateChanged(ItemEvent e)
      The ItemListener for the months.
      Specified by:
      itemStateChanged in interface ItemListener
      Parameters:
      e - the item event
    • setMonth

      private void setMonth(int newMonth, boolean select)
      Sets the month attribute of the JMonthChooser object. Fires a property change "month".
      Parameters:
      newMonth - the new month value
      select - true, if the month should be selcted in the combo box.
    • setMonth

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

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

      public void setDayChooser(JDayChooser dayChooser)
      Convenience method set a day chooser.
      Parameters:
      dayChooser - the day chooser
    • 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
    • getLocale

      public Locale getLocale()
      Returns the locale.
      Overrides:
      getLocale in class Component
      Returns:
      the locale value
      See Also:
    • setLocale

      public void setLocale(Locale l)
      Set the locale and initializes the new month names.
      Overrides:
      setLocale in class Component
      Parameters:
      l - the new locale value
      See Also:
    • setEnabled

      public void setEnabled(boolean enabled)
      Enable or disable the JMonthChooser.
      Overrides:
      setEnabled in class JComponent
      Parameters:
      enabled - the new enabled value
    • getComboBox

      Returns the month chooser's comboBox text area (which allow the focus to be set to it).
      Returns:
      the combo box
    • 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
    • setFont

      public void setFont(Font font)
      Sets the font for this component.
      Overrides:
      setFont in class JComponent
      Parameters:
      font - the desired Font for this component
    • updateUI

      public void updateUI()
      Updates the UI.
      Overrides:
      updateUI in class JPanel
      See Also:
    • 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