Beispiel #1
0
 /**
  * Set calendar to this week's Monday; set year and week combo boxes to the currently set date;
  * set the date labels appropriately; and, refresh the review table.
  */
 private void updateYearWeekDates() {
   yearWeekCalendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
   yearWeekCalendar.set(Calendar.HOUR_OF_DAY, 0);
   yearWeekCalendar.set(Calendar.MINUTE, 0);
   yearWeekCalendar.set(Calendar.SECOND, 0);
   yearWeekCalendar.set(Calendar.MILLISECOND, 0);
   yearCB.setSelectedItem(yearWeekCalendar.get(Calendar.YEAR));
   weekCB.setSelectedItem(yearWeekCalendar.get(Calendar.WEEK_OF_YEAR));
   fromDate.setDate(yearWeekCalendar);
   yearWeekCalendar.add(Calendar.DAY_OF_MONTH, 7);
   toDate.setDate(yearWeekCalendar);
   yearWeekCalendar.add(Calendar.DAY_OF_MONTH, -7);
   refreshReviewTable();
 }
Beispiel #2
0
 {
   addItem("Custom");
   int currentYear = yearWeekCalendar.get(Calendar.YEAR);
   for (int year = currentYear - 5; year <= currentYear + 5; year++) addItem(year);
   addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent ae) {
           if (yearCB.getSelectedIndex() == 0) return;
           yearWeekCalendar.set(Calendar.YEAR, (Integer) yearCB.getSelectedItem());
           updateYearWeekDates();
         }
       });
 }
Beispiel #3
0
 /** Refreshes the label's text according to the current date. */
 private void refresh() {
   setText(dateFormat.format(calendar.getTime()));
 }
Beispiel #4
0
 /**
  * Obtains the date associated with the label.
  *
  * @return The date.
  */
 Date getDate() {
   return calendar.getTime();
 }
Beispiel #5
0
 /**
  * A method used to set the date externally (not through {@link DateChooser}).
  *
  * @param calendar The calendar to clone.
  */
 void setDate(GregorianCalendar calendar) {
   this.calendar = (GregorianCalendar) calendar.clone();
   refresh();
 }