Listing One
//******************
// calendar.java:       Applet
//******************
import java.applet.*;
import java.awt.*;
import java.util.Date;

//=================================
// Main Class for applet calendar
//=================================
public class calendar extends Applet
{
        // PARAMETER SUPPORT: Parameters allow an HTML author to pass
        // information to the applet; the HTML author specifies them using the
        // <PARAM> tag within the <APPLET> tag. The following variables are 
        // used to store the values of the parameters.
    //--------------------------------

    // Members for applet parameters
    // <type>       <MemberVar>    = <Default Value>
    //--------------------------------
        private int m_month = 0;
        private int m_year = 1980;
        private int m_bgcolor = 16777215;  // white
        private int m_fgcolor = 0;

    // Parameter names.  To change a name of a parameter, you need only make
    // a single change.  Simply modify the value of the parameter string below.
    //--------------------------------
        private final String PARAM_month = "month";
        private final String PARAM_year = "year";
        private final String PARAM_bgcolor = "bgcolor";
        private final String PARAM_fgcolor = "fgcolor";

        // calendar Class Constructor
        //--------------------------------
        public calendar()
        {
                // TODO: Add constructor code here
        }
        // APPLET INFO SUPPORT: The getAppletInfo() method returns a string
        // describing the applet's author, copyright date,
        // or miscellaneous information.
    //--------------------------------
        public String getAppletInfo()
        {
         return "Name: calendar\r\n" +
           "Author: Al Williams alw@al-williams.com\r\n" +
           "Created with Microsoft Visual J++ Version 1.1";
        }
        // PARAMETER SUPPORT. The getParameterInfo() method returns an array 
        // of strings describing the parameters understood by this applet.
    // calendar Parameter Information:

    //  { "Name", "Type", "Description" },
    //--------------------------------
        public String[][] getParameterInfo()
        {
                String[][] info =
                {
                 { PARAM_month, "int", "Month" },
                 { PARAM_year, "int", "Year" },
                 { PARAM_bgcolor, "int",
                   "Background color" },
                 { PARAM_fgcolor, "int",
                   "Parameter description" },
                };
                return info;
        }
        // The init() method is called by AWT when an applet is first loaded or
        // reloaded. Override this method to perform whatever initialization 
        // your applet needs, such as initializing data structures, loading 
        // images or fonts, creating frame windows, setting the layout manager,
        // or adding UI components.
    //--------------------------------
        public void init()
        {
          // PARAMETER SUPPORT. The following code retrieves the
          // value of each parameter specified with the <PARAM> tag
          // and stores it in a member variable.
          //----------------------------
                String param;
                // month: Month
                //----------------------------
                param = getParameter(PARAM_month);
                if (param != null)
                    m_month = Integer.parseInt(param);
                // year: Year
                //----------------------------
                param = getParameter(PARAM_year);
                if (param != null)
                    m_year = Integer.parseInt(param);
                // bgcolor: Background color
                //----------------------------
                param = getParameter(PARAM_bgcolor);
                if (param != null)
                    m_bgcolor = Integer.parseInt(param);

                // fgcolor: Parameter description
                //----------------------------
                param = getParameter(PARAM_fgcolor);
                if (param != null)
                    m_fgcolor = Integer.parseInt(param);
        }
        // Place additional applet clean up code here. destroy() is called when
        // when you applet is terminating and being unloaded.
        //-------------------------------
        public void destroy()
        {

                // TODO: Place applet cleanup code here
        }
        // calendar Paint Handler
        //--------------------------------
        public void paint(Graphics g)
        {
                FontMetrics fm;
                int margin;
                int i,j;
                // height and width of each cell
                int cellheight,cellwidth;
                String months[]= // names of months
                {
                 "January","February","March", "April",
                 "May", "June", "July", "August",
                 "September", "October", "November",
                 "December"
                 };
                String days[]= // names of days
                {
                        "Sun","Mon","Tue",
                        "Wed","Thu","Fri","Sat"
                };
                int len[]= { // 30 days hath September...
                 31, 28, 31, 30, 31,
                 30, 31, 31, 30, 31, 30, 31 };
                int row=0;  // current drawing row
                String title;  // title at top
                Color fg,bg;  // colors
                Rectangle r;
                r=bounds();
                fm=g.getFontMetrics();
                margin=3*fm.getHeight(); // top portion
                cellwidth=r.width/7;
                cellheight=(r.height-margin)/6;
                fg=new Color(m_fgcolor);
                bg=new Color(m_bgcolor);
                g.setColor(bg);
                // draw header
                g.fillRect(0,0,7*cellwidth,margin);
                Integer yr;
                yr=new Integer(m_year);
                title=months[m_month]+" "+yr.toString();
                g.setColor(fg);
                g.drawString(title,10,fm.getHeight());
                // draw cells
                for (j=0;j<7;j++)
                {
                    g.drawString(days[j],
                      j*cellwidth+cellwidth/2-10,
                      fm.getHeight()*2); // day names
                    for (i=0;i<6;i++)
                    {
                        g.setColor(bg); // draw inside
                        g.fillRect(j*cellwidth,margin+

                           i*cellheight,cellwidth,
                           cellheight);
                        g.setColor(fg); // draw outside
                        g.drawRect(j*cellwidth,
                           margin+i*cellheight,
                           cellwidth,cellheight);
                    }
                }
                j=len[m_month];
                // add one for leap years
                if (m_month==1 && m_year%4 == 0) j++;
                // draw dates
                for (i=0;i<j;i++)
                {
                   Date date = new Date(m_year-1900,
                      m_month,i+1);
                   Integer day= new Integer(date.getDay());
                   Integer I= new Integer(i+1);
                   g.drawString(I.toString(),
                     day.intValue()*cellwidth+cellwidth/2,
                     margin+cellheight*row+cellheight/2);
                   if (day.intValue()==6) row++;
                }
        }
        // The start() method is called when the page containing the applet
        // first appears on the screen. AppletWizard's initial implementation
        // of this method starts execution of the applet's thread.
        //--------------------------------
        public void start()
        {
                // TODO: Place additional applet start code here
        }
        // The stop() method is called when the page containing the applet is
        // no longer on the screen. AppletWizard's initial implementation of
        // this method stops execution of the applet's thread.
        //--------------------------------
        public void stop()
        {
        }
        // TODO: Place additional applet code here
}

Listing Two
<html>
<head>
<title>calendar</title>
</head>
<body>
<hr>
<applet
    code=calendar.class
    name=calendar
    ID=cal
    width=320
    height=240 >

    <param name=month value="1">
    <param name=year value="1980">
    <param name=events value="">
    <param name=bgcolor value=16777215>
    <param name=fgcolor value=0>
</applet>
<hr>
</body>
</html>


