Java Reference
In-Depth Information
monthChoice.add("Feb");
monthChoice.add("Mar");
monthChoice.add("Apr");
monthChoice.add("May");
monthChoice.add("Jun");
monthChoice.add("Jul");
monthChoice.add("Aug");
monthChoice.add("Sep");
monthChoice.add("Oct");
monthChoice.add("Nov");
monthChoice.add("Dec");
monthChoice.addItemListener(this);
Panel top = new Panel();
top.add(monthChoice);
top.add(yearLabel);
top.add(buttonMinus);
top.add(buttonPlus);
buttonPlus.addActionListener(this);
buttonMinus.addActionListener(this);
add("North", top);
add("Center", calendarCanvas);
propagate();
}
public void setDate (Date date) {
calendar.setTime (date);
propagate();
}
void propagate() {
calendar.set
(Calendar.DAY_OF_MONTH,
calendarCanvas.getCalendar().get
(Calendar.DAY_OF_MONTH));
calendarCanvas.setDate (calendar.getTime());
yearLabel.setText (""+calendar.get(Calendar.YEAR));
monthChoice.select
(calendar.get (Calendar.MONTH)-Calendar.JANUARY);
repaint();
}
public Date getDate() {
calendar.set (Calendar.DAY_OF_MONTH,
calendarCanvas.getCalendar().get
(Calendar.DAY_OF_MONTH));
return calendar.getTime();
}
public void itemStateChanged (ItemEvent ev) {
Search WWH ::




Custom Search