Wrox Programmer Forums
|
Pro JSP Advanced JSP coding questions. Beginning questions will be redirected to the Beginning JSP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro JSP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 9th, 2008, 07:54 PM
Authorized User
 
Join Date: Jul 2006
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ironchef
Default Calendar(cont)

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
__________________
<b>IronChef</b> - http://www.freewebs.com/cool_recipes





Similar Threads
Thread Thread Starter Forum Replies Last Post
Calendar like calendar in AJAX in ASP.NET h@ckerz ASP.NET 2.0 Professional 0 February 19th, 2008 12:56 AM
Updating a database with new records modified cont bright_mulenga Access 0 January 18th, 2007 10:59 AM
Cont\ent Types jbenson001 ASP.NET 1.x and 2.0 Application Design 4 February 6th, 2004 01:53 PM
Access help, subform on a cont. form akwormy Access VBA 1 December 28th, 2003 05:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.