Пример #1
1
  public void stateChanged(ChangeEvent e) {
    JSpinner source = (JSpinner) e.getSource();
    Calendar c = this.getDateCalendar();
    if (source.getName().equals("Hour")) {
      c.set(Calendar.HOUR_OF_DAY, getSelectedHour());
      this.date = c.getTime();
      return;
    } else if (source.getName().equals("Minute")) {
      c.set(Calendar.MINUTE, getSelectedMinute());
      this.date = c.getTime();
      return;
    } else if (source.getName().equals("Second")) {
      c.set(Calendar.SECOND, getSelectedSecond());
      this.date = c.getTime();
      return;
    }
    dayColorUpdate(true);

    if (source.getName().equals("Year")) {
      c.set(Calendar.YEAR, getSelectedYear());
    } else {
      c.set(Calendar.MONTH, getSelectedMonth() - 1);
    }
    this.date = c.getTime();
    flushWeekAndDay();
  }
Пример #2
0
 public void actionPerformed(ActionEvent e) {
   JButton source = (JButton) e.getSource();
   if (source.getText().length() == 0) return;
   dayColorUpdate(true);
   source.setForeground(todayBackColor);
   int newDay = Integer.parseInt(source.getText());
   Calendar c = getDateCalendar();
   c.set(Calendar.DAY_OF_MONTH, newDay);
   this.date = c.getTime();
 }
Пример #3
0
 private void flushWeekAndDay() {
   Calendar c = this.getDateCalendar();
   c.set(Calendar.DAY_OF_MONTH, 1);
   int maxDayNo = c.getActualMaximum(Calendar.DAY_OF_MONTH);
   int dayNo = 2 - c.get(Calendar.DAY_OF_WEEK);
   for (int i = 0; i < 6; i++) {
     for (int j = 0; j < 7; j++) {
       String s = "";
       if (dayNo >= 1 && dayNo <= maxDayNo) s = String.valueOf(dayNo);
       daysButton[i][j].setText(s);
       dayNo++;
     }
   }
   dayColorUpdate(false);
 }