Beispiel #1
0
  /**
   * This is the constructor of the class it creates all of the weekDayBlocks that are associated
   * with this class and sets the currently selected date and creates a weekRange around that date
   *
   * @param date is the currentlySelectedDate
   */
  public WeeklyPanel(Date date) {
    super();

    blocks = new ArrayList<WeeklyDayBlock>();

    JPanel daysPanel = new JPanel();
    daysPanel.setOpaque(false);
    daysPanel.setLayout(new GridLayout(1, 7));

    Calendar tmpCal = Calendar.getInstance();
    WeekRange week = new WeekRange();
    tmpCal.setTime(week.getStartDate());
    while (tmpCal.getTime().before(week.getEndDate())) {
      JLabel dayText =
          new JLabel(
              tmpCal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.getDefault()));
      dayText.setFont(dayText.getFont().deriveFont(13f).deriveFont(Font.BOLD));
      dayText.setOpaque(false);
      dayText.setHorizontalAlignment(SwingConstants.CENTER);
      daysPanel.add(dayText);
      tmpCal.add(Calendar.DATE, 1);
    }

    JPanel content = new JPanel();
    content.setOpaque(false);
    content.setLayout(new GridLayout(0, 7));

    ButtonGroup group = new ButtonGroup();

    WeekRange thisWeek = new WeekRange(date);
    tmpCal.setTime(thisWeek.getStartDate());
    while (tmpCal.getTime().before(thisWeek.getEndDate())) {
      WeeklyDayBlock currentDay = new WeeklyDayBlock(tmpCal.getTime());
      blocks.add(currentDay);
      content.add(currentDay);
      group.add(currentDay);
      tmpCal.add(Calendar.DATE, 1);
    }

    setLayout(new BorderLayout());
    setOpaque(false);
    add(daysPanel, BorderLayout.NORTH);
    add(content, BorderLayout.CENTER);

    update(new HashSet<RefAppointment>(), date, null);
  }