java - jCalendar cell coloring -
i coloring jcalendar
cell's background mentioned here have stored date employees id when present , saving dates in resultset
variable result , coloring date cells green. upto code working fine, when tried color sundays blue , rest of dates when employee absent red, it's not working. here i'am pasting code-
presenthighlightevaluator pevaluator = new presenthighlightevaluator(); holidayhighlightevaluator hevaluator = new holidayhighlightevaluator(); absenthighlightevaluator aevaluator = new absenthighlightevaluator(); string dburl = "jdbc:derby://localhost:1527/contact;user=nbuser;password=nbuser"; connection conn = null; statement stmt = null; try { class.forname("org.apache.derby.jdbc.clientdriver").newinstance();; //get connection conn = drivermanager.getconnection(dburl); stmt = conn.createstatement(); resultset result = stmt.executequery("select id, date attendance id = '"+id+"'"); //resultset resulta = result; date[] datearr = new date[365]; int j = 0; while(result.next()){ system.out.println(result.getdate("date")); datearr[j] = result.getdate("date"); pevaluator.add(result.getdate("date")); j++; } date date = new date(); date sqldate = new date(date.gettime()); int month = 0, day = 1; java.sql.date dateitretor = new java.sql.date(date.gettime()); //system.out.println(dateitretor); dateitretor.setmonth(month); dateitretor.setdate(day); dateitretor.setyear(date.getyear()); //system.out.println(dateitretor); result.next(); int = 0; while(dateitretor.before(sqldate)){ system.out.println("under while "+ dateitretor); if(dateitretor.getday() == 0){ system.out.println("sunday"); hevaluator.add(dateitretor); }else if(dateitretor.equals(datearr[i])){ i++; }else{ aevaluator.add(dateitretor); } calendar c = calendar.getinstance(); c.settime(dateitretor); c.add(calendar.date, 1); date = c.gettime(); dateitretor = new java.sql.date(date.gettime()); //system.out.println(dateitretor); } jcalendar1.getdaychooser().adddateevaluator(pevaluator); jcalendar1.getdaychooser().adddateevaluator(hevaluator); jcalendar1.getdaychooser().adddateevaluator(aevaluator); jcalendar1.setcalendar(jcalendar1.getcalendar()); }catch(exception except) { except.printstacktrace(); }
where presenthighlightevaluator, absenthighlightevaluator , holidayhighlightevaluator classes defined highlightevaluator class given in post mentioned returning green, red , blue color in method getspecialbackroundcolor.
wiki
Comments
Post a Comment