Class tea.set.Calendar
All Packages Class Hierarchy This Package Previous Next Index
Class tea.set.Calendar
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Canvas
|
+----tea.set.Calendar
- public class Calendar
- extends Canvas
Calendar widget provides an interface to manipulate one month calendar.
It handles calendar related calculation automatically. There are a
number of options to control the apperance of the calendar. Users can
interact with the calendar by selecting one day or a day range. One
or more days can be highlighted from the program. Calendar widget
calculates the optimum size to display a calendar. But if the widget
is resized to a size other than the default, the layout of the
calendar is automatically recalculated to lay the days out evenly
over the available space. Since setYear() and setMonth() clears
all selections, select() should be called after these functions.
-
ALL
- Display year, month name, and weekday.
-
MONTH_WEEK
- Display weekday header and month name.
-
NO_TITLE
- Display only days.
-
WEEK
- Display weekday header (Monday - Sunday).
-
Calendar()
- Create a new calendar containing the current month.
-
Calendar(int, int)
- Create a monthly calendar for year/month.
-
action(Event, Object)
- Action routine is called when a day or a day range is selected.
-
clear()
- Clear any outstanding selection.
-
compareTo(Calendar)
- Return the difference in month between this and mon.
-
dayOfWeek(int, int, int)
- Return the day of week for year/month/day.
-
daysInMonth(int, int)
- Return the number of days in month.
-
dehighlight(int)
- De-highlight the specified day.
-
dehighlight(int, int)
- De-highlight the specified days in the range, inclusive.
-
equals(Object)
- Return true if the Calendars have same year and month.
-
getEndDay()
- Return the end day (inclusive) of a selected date range.
-
getMonth()
- Return the month of the calendar.
-
getMonthName(int)
- Return the three letter month name for month m.
-
getStartDay()
- Get the start day of a selected date range.
-
getYear()
- Return the year of this calendar.
-
highlight(int)
- Highlight the specified day.
-
highlight(int, int)
- Highlight the specified days in the range, inclusive.
-
isHighlighted(int)
- Return true if the specified day is highlighted.
-
minimumSize()
-
Return the minimum size of the widget.
-
mouseDown(Event, int, int)
- Set the starting selection point to the day where the mouse
pointer is in.
-
mouseDrag(Event, int, int)
- Day range selection.
-
mouseUp(Event, int, int)
- Set the ending point of the selection to the day where the
mouse pointer is in.
-
paint(Graphics)
- Paint the calendar.
-
preferredSize()
- Return the preferred size of the widget.
-
select(int)
- Select the specified day.
-
select(int, int)
- Select the specified day range.
-
selectAll()
- Mark the entire month as selected.
-
setHighlight(Color)
- Set the highlight color.
-
setMonth(int)
- Set the month of the calendar.
-
setTitle(int)
- Set the title option to either no title, weekday only,
month and weekday, or all.
-
setYear(int)
- Set the year of the calendar.
-
toString()
- Converts to a string representation.
-
update(Graphics)
- For double buffering.
NO_TITLE
public final static int NO_TITLE
- Display only days.
WEEK
public final static int WEEK
- Display weekday header (Monday - Sunday).
MONTH_WEEK
public final static int MONTH_WEEK
- Display weekday header and month name.
ALL
public final static int ALL
- Display year, month name, and weekday.
Calendar
public Calendar()
- Create a new calendar containing the current month.
Calendar
public Calendar(int year,
int month)
- Create a monthly calendar for year/month.
Year starts from 1900, so pass 96 for 1996.
Month starts from 0 to 11, corresponding to Jan to Dec respectively.
- Parameters:
- year - calendar year, year subtract 1900.
- month - calendar month, starts from 0.
setTitle
public void setTitle(int flag)
- Set the title option to either no title, weekday only,
month and weekday, or all. This causes a repaint.
- Parameters:
- flag - title flag, one of the title option values.
setYear
public void setYear(int year)
- Set the year of the calendar. This causes a repaint.
- Parameters:
- year - calendar year.
getYear
public int getYear()
- Return the year of this calendar.
- Returns:
- calendar year.
setMonth
public void setMonth(int month)
- Set the month of the calendar. This causes a repaint.
- Parameters:
- month - calendar month.
getMonth
public int getMonth()
- Return the month of the calendar.
- Returns:
- calendar month, 0-11.
highlight
public void highlight(int day)
- Highlight the specified day.
- Parameters:
- day - day number, starts from 1.
highlight
public void highlight(int sday,
int eday)
- Highlight the specified days in the range, inclusive.
- Parameters:
- sday - starting day of highlight range, starts from 1.
- eday - ending day of highlight range, starts from 1.
dehighlight
public void dehighlight(int day)
- De-highlight the specified day.
- Parameters:
- day - number starts from 1.
dehighlight
public void dehighlight(int sday,
int eday)
- De-highlight the specified days in the range, inclusive.
- Parameters:
- sday - starting day number of range, starts from 1.
- eday - ending day number of range, starts from 1.
isHighlighted
public boolean isHighlighted(int day)
- Return true if the specified day is highlighted.
- Parameters:
- day - day number starts from 1.
setHighlight
public void setHighlight(Color c)
- Set the highlight color. Defaults to red.
- Parameters:
- c - highlight color.
minimumSize
public Dimension minimumSize()
- Return the minimum size of the widget.
- Returns:
- minimum size of calendar.
- Overrides:
- minimumSize in class Component
preferredSize
public Dimension preferredSize()
- Return the preferred size of the widget.
- Parameters:
- preferred - size of calendar.
- Overrides:
- preferredSize in class Component
action
public boolean action(Event e,
Object o)
- Action routine is called when a day or a day range is selected.
The argument object is a reference to Calendar itself.
- Parameters:
- e - event object.
- o - event argument object.
- Returns:
- always false.
- Overrides:
- action in class Component
getStartDay
public int getStartDay()
- Get the start day of a selected date range. Return -1 if
no selection is made. Day number starts at 1.
- Returns:
- day number of the starting point of selected day range.
-1 if no selection is made.
getEndDay
public int getEndDay()
- Return the end day (inclusive) of a selected date range.
Return -1 if no selection is made. Day number starts at 1.
- Returns:
- day number of the ending point of selected day range.
-1 if no selection is made.
clear
public void clear()
- Clear any outstanding selection. This could cause a repaint
if there is a range selected.
select
public void select(int day)
- Select the specified day. No event is generated by this function.
- Parameters:
- day - number starts from 1.
select
public void select(int sday,
int eday)
- Select the specified day range. No event is generated by this
funciton.
- Parameters:
- sday - starting day of range, starts from 1.
- eday - ending day of range, starts from 1.
selectAll
public void selectAll()
- Mark the entire month as selected.
equals
public boolean equals(Object mon)
- Return true if the Calendars have same year and month.
- Parameters:
- mon - Calendar object for comparison.
- Returns:
- true if calendar year and month are same.
- Overrides:
- equals in class Object
compareTo
public int compareTo(Calendar mon)
- Return the difference in month between this and mon.
toString
public String toString()
- Converts to a string representation.
- Returns:
- string representation of canlendar.
- Overrides:
- toString in class Component
update
public void update(Graphics g)
- For double buffering.
- Parameters:
- g - Graphics content of this component.
- Overrides:
- update in class Component
paint
public void paint(Graphics g)
- Paint the calendar.
- Parameters:
- g - Graphics content of this component.
- Overrides:
- paint in class Canvas
mouseDown
public boolean mouseDown(Event e,
int x,
int y)
- Set the starting selection point to the day where the mouse
pointer is in.
- Parameters:
- e - event object.
- x - x coordinate of the mouse click point.
- y - y coordinate of the mouse click point.
- Overrides:
- mouseDown in class Component
mouseUp
public boolean mouseUp(Event e,
int x,
int y)
- Set the ending point of the selection to the day where the
mouse pointer is in.
- Parameters:
- e - event object.
- x - x coordinate of the mouse click point.
- y - y coordinate of the mouse click point.
- Overrides:
- mouseUp in class Component
mouseDrag
public boolean mouseDrag(Event e,
int x,
int y)
- Day range selection.
- Parameters:
- e - event object.
- x - x coordinate of the mouse click point.
- y - y coordinate of the mouse click point.
- Overrides:
- mouseDrag in class Component
daysInMonth
public static int daysInMonth(int year,
int month)
- Return the number of days in month. Month starts from zero(0).
- Parameters:
- year - year is the year minus 1900.
- month - month starts from 0-11.
- Returns:
- number of days in the month.
dayOfWeek
public static int dayOfWeek(int year,
int month,
int day)
- Return the day of week for year/month/day. Sunday is 0.
- Parameters:
- year - year is the year minus 1900.
- month - month starts from 0-11.
- day - day starts from 1.
- Returns:
- 0 for Sunday, 1 for monday, and so on.
getMonthName
public static String getMonthName(int m)
- Return the three letter month name for month m. Month starts from 0.
- Parameters:
- m - month number, starts from 0.
- Returns:
- month name.
All Packages Class Hierarchy This Package Previous Next Index