Okay, so ive modified the calendar program to display appoint ments but for some reason it shows all the dates up to the first day with appointments. then it shows the appoinments for that day and the date # for the next day, but then it doesnt show any appoinments or date #s after that. Here is the code i have in the paint section of my applet:
public void paint(Graphics g)
/*
USE: Draw calendar using globals userMonth and userYear.
NOTE: Called automatically whenever surface needs to be redrawn;
also when user clicks 'New Calendar' button, triggering repaint.
*/
{
FontMetrics fm; /* to get font info */
int fontAscent; /* character height */
int dayPos; /* y-position of day strings */
int xSize, ySize; /* size of calendar body (cell table) */
int numRows; /* number of rows in cell table (4, 5, 6) */
int xNum, yNum, yText; /* number position at top right of cells */
int numDays; /* number of days in month */
String dayStr, apptStr; /* day of the week as a string */
int marg; /* margin of month string baseline from cell table */
String caption; /* month string at top center */
JobDue[] curJobs;
JobDue curJob;
int curJobNum = 0;
int idNum = 0;
// Get x-size of calendar body (cell table).
xSize = NCELLX * CELLSIZE;
// Set large font for month/year caption.
g.setFont(largeArialFont);
// Get font info for string positioning (large font now current).
fm = g.getFontMetrics();
// Set margin for y-positioning of caption.
marg = 2 * fm.getDescent();
// Set caption to month string and center at top.
caption = months[userMonth] + " " + String.valueOf(userYear);
g.drawString(caption, (xSize-fm.stringWidth(caption))/2, YTOP - marg);
g.setFont(smallArialFont);
// Get font info for number string positioning (default small font).
fm = g.getFontMetrics();
fontAscent = fm.getAscent();
dayPos = YTOP + (YHEADER + fontAscent) / 2;
// Header rectangle across top for day names.
g.drawRect(0, YTOP, xSize, YHEADER);
// Put days at top of each column, centered.
for (int i = 0; i < NCELLX; i++)
g.drawString(days[i], (CELLSIZE-fm.stringWidth(days[i]))/2 + i*CELLSIZE,
dayPos);
// Get number of calendar rows needed for this month.
numRows = NumberRowsNeeded(userYear, userMonth);
// Vertical lines of cell table.
ySize = numRows * CELLSIZE;
for (int i = 0; i <= xSize; i += CELLSIZE)
g.drawLine(i, YTOP + YHEADER, i, YTOP + YHEADER + ySize);
// Horizontal lines of cell table.
for (int i = 0, j = YTOP + YHEADER; i <= numRows; i++, j += CELLSIZE)
g.drawLine(0, j, xSize, j);
// Init number positions (upper right of cell).
xNum = (CalcFirstOfMonth(userYear, userMonth) + 1) * CELLSIZE - MARGIN;
yNum = YTOP + YHEADER + MARGIN + fontAscent;
yText = yNum - MARGIN - fontAscent - MARGIN + CELLSIZE;
// Get number of days in month, adding one if February of leap year.
numDays = DaysInMonth[userMonth] +
((IsLeapYear(userYear) && (userMonth == FEBRUARY)) ? 1 : 0);
// Show numbers at top right of each cell, right justified.
for (int day = 1; day <= numDays; day++)
{
dayStr = String.valueOf(day);
g.drawString(dayStr, xNum - fm.stringWidth(dayStr), yNum);
//get number of jobs in a current day
for(int i = 0; i < jobs.length; i++) {
curJob = jobs[i];
if(curJob.getDay() == day && curJob.getMonth() == userMonth)
curJobNum++;
}
if(curJobNum != 0) {
curJobs = new JobDue[curJobNum];
for(int i = 0; i < jobs.length; i++) {
curJob = jobs[i];
if(curJob.getDay() == day && curJob.getMonth() == userMonth){
curJobs[idNum] = curJob;
idNum++;
}
}
//show appointments
for(int i = 0; i < curJobs.length; i++) {
apptStr = curJobs[i].getDisplay();
g.drawString(apptStr, xNum - fm.stringWidth(apptStr), yText);
yText = yText - fontAscent - SEPERATOR;
}
yText = yText + curJobs.length * (fontAscent + SEPERATOR);
}
xNum += CELLSIZE;
// If xNum to right of calendar, 'new line'.
if (xNum > xSize)
{
xNum = CELLSIZE - MARGIN;
yNum += CELLSIZE;
yText += CELLSIZE;
} // if
} // for
} // paint
THANK YOU!!! AND PLEASE REPLY SOON!!!!
IronChef -
http://www.freewebs.com/cool_recipes