net.sf.nachocalendar.components

Class MonthScroller


public class MonthScroller
extends javax.swing.JPanel

Component used to change the current month. It extends from JComboBox and has two arrows for unitary changes. It fires a YearChangeEvent when the month under or overflows. It also fires a ChangeEvent when the month is changed.
Author:
Ignacio Merani

Constructor Summary

MonthScroller()
Creates new form MonthScroller.

Method Summary

void
addChangeListener(javax.swing.event.ChangeListener listener)
Registers ChangeListener to receive events.
void
addYearChangeListener(YearChangeListener listener)
Registers YearChangeListener to receive events.
int
getMonth()
Returns the current month.
boolean
isEnabled()
Getter for enabled property.
void
nextMonth()
Changes to the next month.
void
previousMonth()
Changes to the previous month.
void
removeChangeListener(javax.swing.event.ChangeListener listener)
Removes ChangeListener from the list of listeners.
void
removeYearChangeListener(YearChangeListener listener)
Removes YearChangeListener from the list of listeners.
void
setEnabled(boolean b)
Enables or disables the component.
void
setMonth(int month)
Changes de current month.
void
setNextIcon(Icon icon)
Changes the icon for the Next button.
void
setNextText(String text)
Changes the text of the Next button.
void
setPreviousIcon(Icon icon)
Changes the icon for the Previous button.
void
setPreviousText(String text)
Changes the text of the Previous button.

Constructor Details

MonthScroller

public MonthScroller()
Creates new form MonthScroller.

Method Details

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener listener)
Registers ChangeListener to receive events.
Parameters:
listener - The listener to register.

addYearChangeListener

public void addYearChangeListener(YearChangeListener listener)
Registers YearChangeListener to receive events.
Parameters:
listener - The listener to register.

getMonth

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

isEnabled

public boolean isEnabled()
Getter for enabled property.
Returns:
true if it's enabled

nextMonth

public void nextMonth()
Changes to the next month.

previousMonth

public void previousMonth()
Changes to the previous month.

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener listener)
Removes ChangeListener from the list of listeners.
Parameters:
listener - The listener to remove.

removeYearChangeListener

public void removeYearChangeListener(YearChangeListener listener)
Removes YearChangeListener from the list of listeners.
Parameters:
listener - The listener to remove.

setEnabled

public void setEnabled(boolean b)
Enables or disables the component.
Parameters:
b - true for enabling

setMonth

public void setMonth(int month)
Changes de current month.
Parameters:
month - new month

setNextIcon

public void setNextIcon(Icon icon)
Changes the icon for the Next button.
Parameters:
icon - new Icon or null to show the default arrow

setNextText

public void setNextText(String text)
Changes the text of the Next button.
Parameters:
text - new text or null to show the default arrow

setPreviousIcon

public void setPreviousIcon(Icon icon)
Changes the icon for the Previous button.
Parameters:
icon - new Icon or null to show the default arrow

setPreviousText

public void setPreviousText(String text)
Changes the text of the Previous button.
Parameters:
text - new text or null to show the default arrow