The source code shown below comes from two files. The first holds the CalendarPanel class (CalendarPanel.java), and the second controls the Applet(iNetCal.java)
If you have any questions or comments about the code, contact me at 


CalendarPanel.java

import java.awt.*;
import java.util.*;

class CalendarPanel extends Panel {

  private boolean visible = false;
  private String monthString;
  private int date;
  private int year;
  private int month;

  public CalendarPanel() {
    super();
    validate();
  }

  static int getMonthDays(int month, int year) {

    int numDays=0;
    //without next line, leap year isn't calculated properly
    switch (month) {
      case 1:
      case 3:
      case 5:
      case 7:
      case 8:
      case 10:
      case 12: numDays = 31; break;
      case 4:
      case 6:
      case 9:
      case 11: numDays = 30; break;
      case 2:
        if ( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400==0) ) {
          numDays = 29;
        } else {
          numDays = 28;
        } break;
      }
// System.out.println(numDays);
  return numDays;
  }

  String getMonthName(int month) {
  String monthName;
    switch (month) {
      case 1: monthName = "January"; break;
      case 2: monthName = "February"; break;
      case 3: monthName = "March"; break;
      case 4: monthName = "April"; break;
      case 5: monthName = "May"; break;
      case 6: monthName = "June"; break;
      case 7: monthName = "July"; break;
      case 8: monthName = "August"; break;
      case 9: monthName = "September"; break;
      case 10: monthName = "October"; break;
      case 11: monthName = "November"; break;
      case 12: monthName = "December"; break;
      default: monthName = "invalid month ";break;
    }
    return monthName;

  }

  public void showDate(Date d) {
    visible = true;
    month = d.getMonth()+1;
    monthString= getMonthName(month);
    date = d.getDate();
    year = d.getYear()+1900;
    repaint();
  }

  public void paint(Graphics g) {

    int headerHeight;
    int currDate;
    Date firstDate;
    int startDay;
    String currCell;

    if (visible) {

      firstDate = new Date(year-1900, month-1, 1);
      startDay = firstDate.getDay();
      Dimension d = size();
      d.width = (d.width - (d.width % 7)-6);
      FontMetrics fontMetrics = g.getFontMetrics(g.getFont());

      String header = monthString + " " + java.lang.Integer.toString(date) +", "+ java.lang.Integer.toString(year);

      //draw border in the same color as form background
      g.setColor(getBackground());
      g.setColor(Color.lightGray);
      g.draw3DRect(0,0, d.width-1, d.height - 1, true);
            g.draw3DRect(3,3, d.width - 7, d.height-7, false);
      g.setColor(Color.black);
      g.drawRect(0,0,d.width-1, d.height-1);

      //draw the header
      g.setColor(Color.gray);
      headerHeight =fontMetrics.getHeight()+5;
      headerHeight = headerHeight+((d.height-8-headerHeight) % 7);
      g.fillRect(4,3, d.width - 8, headerHeight);
      g.setColor(Color.black);
          g.drawRect(4,3, d.width - 8, headerHeight);
      //get height centered too on below line-XOPHER
      g.drawString(header, (d.width/2)-(fontMetrics.stringWidth(header)/2) ,fontMetrics.getHeight()+3);

      //draw cells
      int cellY = (d.width-8)/7;
      int cellX = (d.height-headerHeight-8)/7;
      g.setColor(Color.black);
      for (int i=0; i<7; i++) {
        for (int j=0; j<7; j++) {
          g.drawRect(4 + (i*cellY),headerHeight+3 + (j*cellX), cellY, cellX);
          currDate = ((j-1) * 7) + i - startDay + 1;

          if (currDate == date) {
            g.setColor(Color.green);
            g.fillRect(5 + (i*cellY),headerHeight+4 + (j*cellX), cellY-1, cellX-1);
            g.setColor(Color.black);
          }
          currCell = " ";
          if (j==0) {
            g.drawRect(4 + (i*cellY),headerHeight+3 + (j*cellX), cellY, cellX);
            g.setColor(Color.lightGray);
            g.fillRect(5 + (i*cellY),headerHeight+4 + (j*cellX), cellY-1, cellX-1);
            g.setColor(Color.black);
            switch (i) {
              case 0: currCell="Sun"; break;
              case 1: currCell="Mon"; break;
              case 2: currCell="Tue"; break;
              case 3: currCell="Wed"; break;
              case 4: currCell="Thu"; break;
              case 5: currCell="Fri"; break;
              case 6: currCell="Sat"; break;
            }
         } else if (((i >= startDay) || (j>1)) && (currDate <= getMonthDays(month, year))) {
            currCell = java.lang.Integer.toString(currDate);
          }
          g.drawString(currCell, 14 + (i*cellY), 14 + headerHeight+3 + (j*cellX));
          if (currCell == " ") {
            g.setColor(Color.darkGray);
            g.fillRect(5 + (i*cellY),headerHeight+4 + (j*cellX), cellY-1, cellX-1);
            g.setColor(Color.black);
          }


        }
      }

    }
  }


}

CalendarPanel.java

import java.awt.*;
import java.applet.*;
import java.util.*;

public class INetCal extends Applet {

  Date d = new Date();
  private boolean locked=false;

  Panel choicePanel;

  Choice monthChoice;
  Choice dayChoice;
  Choice yearChoice;
  Button calcDueDate;

  CalendarPanel calPanel;

  public void init() {

    setBackground(Color.white);

    setLayout(new BorderLayout());
    choicePanel = new Panel();

    add("North", choicePanel);

    monthChoice = new Choice();
    monthChoice.addItem("January");
            monthChoice.addItem("February");
    monthChoice.addItem("March");
    monthChoice.addItem("April");
    monthChoice.addItem("May");
    monthChoice.addItem("June");
    monthChoice.addItem("July");
    monthChoice.addItem("August");
    monthChoice.addItem("September");
    monthChoice.addItem("October");
                monthChoice.addItem("November");
                monthChoice.addItem("December");
                choicePanel.add(monthChoice);

                yearChoice = new Choice();
        yearChoice.addItem(java.lang.Integer.toString(d.getYear()+1900-1));
    yearChoice.addItem(java.lang.Integer.toString(d.getYear()+1900));
    yearChoice.addItem(java.lang.Integer.toString(d.getYear()+1900+1));
    yearChoice.addItem(java.lang.Integer.toString(d.getYear()+1900+2));
    yearChoice.addItem(java.lang.Integer.toString(d.getYear()+1900+3));
    choicePanel.add(yearChoice);

              setDayChoice(monthChoice.getSelectedIndex() + 1, yearChoice.getSelectedIndex() -1 + d.getYear());

    monthChoice.select(d.getMonth());
    dayChoice.select(d.getDate()-1);
    yearChoice.select(1);

    calcDueDate = new Button("Calculate Due Date");
    choicePanel.add(calcDueDate);

    calPanel = new CalendarPanel();
    add("Center", calPanel);


    validate();
  }

  private void lockDisplay() {
    locked = true;
  }

  private void unLockDisplay() {
    locked = false;
  }

  void setDayChoice(int month, int year) {
    int ii;
    int day = 0;
    lockDisplay();
    if (dayChoice != null) {
      day = dayChoice.getSelectedIndex();
      choicePanel.remove(dayChoice);
    }
    dayChoice = new Choice();
    for (ii = 1; ii <= CalendarPanel.getMonthDays(month, year+1900); ii++) {
     dayChoice.addItem(java.lang.Integer.toString(ii));
    }
    choicePanel.add(dayChoice,1);
          if (day <= dayChoice.countItems()-1) {
      dayChoice.select(day);
    } else {
      dayChoice.select(dayChoice.countItems()-1);
    }
    unLockDisplay();
    validate();
  }

  void printDueDate() {

    Date day = new Date(yearChoice.getSelectedIndex() -1 + d.getYear(),
                        monthChoice.getSelectedIndex(),
                                                          dayChoice.getSelectedIndex() + 1);
          long dueDate = day.getTime();

    //1 ms * 1000= 1 sec * 60 = 1min * 60 = 1 hr * 24 = 1 day
  long oneDay = 1000*60*60*24;
    long gestation = oneDay * 280;
    //following line will cause incorrect date--
    //must break it down to the two lines above
  //long gestation = 1000*60*60*24*280;
    day = null;
    dueDate = gestation + dueDate;
        day = new Date(dueDate);
    calPanel.showDate(day);
  }

  public void update(Graphics g) {
   if (!locked) {
     super.update(g);
   }
  }

  public void paint(Graphics g) {
        if (!locked) {
          super.paint(g);
    }
  }

  public boolean action(Event event, Object arg) {
    if (event.target == calcDueDate) {
          showStatus("calculating due date...");
      printDueDate();
      return true;
    }

    if ((event.target == monthChoice) || (event.target == yearChoice)) {
      setDayChoice(monthChoice.getSelectedIndex() + 1, yearChoice.getSelectedIndex() -1 + d.getYear());
      return true;
    }

        return false;
    
return to geekstuff