java - Codename one calendar UpdateButtonDayDate() issue -
i working on project want show when application starts calendar display, date contain events, instance if date contain events, day button contains * symbol , day, , if date doesn't contain event displays day. wrote following code, displays * symbol when clicking on button, how can manage code display * symbol on date contain events when application starts or page gonna loaded.
following code:-
public class customised extends calendar{ arraylist<string[]> data = new arraylist<>(); int i,j,columns; @override protected void updatebuttondaydate(button daybutton,int currentmonth, int day) { daybutton.settext(""+day); daybutton.addactionlistener(new actionlistener() { @override public void actionperformed(actionevent evt) { //check date having how many number of events=============================================================== try{ showevent.removeall(); cur = db.executequery("select event, description calendardata date = ? ", datelabel.gettext()); columns = cur.getcolumncount(); if(columns > 0) { boolean next = cur.next(); if(next) { string[] columnnames = new string[columns]; for(int iter = 0 ; iter < columns ; iter++) { columnnames[iter] = cur.getcolumnname(iter); } while(next) { row currentrow = cur.getrow(); string[] currentrowarray = new string[columns]; for(int iter = 0 ; iter < columns ; iter++) { currentrowarray[iter] = currentrow.getstring(iter); } data.add(currentrowarray); next = cur.next(); } object[][] arr = new object[data.size()][]; data.toarray(arr); } } }catch(ioexception e){ e.printstacktrace(); } for(i = 0 ; i< data.size(); i++){ log.p(data.get(i)[0]); } label = new label(datelabel.gettext()); label b = new label(" "+i); container container1 = tablelayout.enclosein(2, a,b); container1.setuiid("container1"); showevent.add(container1); for( = 0 ; i< data.size(); i++){ for(j = 0; j<columns; j++){ log.p(data.get(i)[j]); spanlabel spandata = new spanlabel(data.get(i)[j]); spandata.setuiid("spanlabel"); showevent.add(spandata); } label space = new label("======================="); showevent.add(space); log.p("###################"); } data.clear(); if(i>0){ if(dialog.show("choose action", "what want do?", "add events","view events")){ calendar.show(); } else{ showevent.show(); } }else{ dialog.show("add event","there no event display, please add events first","ok",""); } //============================================================================================================ } }); } @override protected void initcomponent(){ arraylist<string[]> data1 = new arraylist<>(); int k; log.p("initcomponent"); try{ cur = db.executequery("select date calendardata"); columns = cur.getcolumncount(); if(columns > 0) { boolean next = cur.next(); if(next) { string[] columnnames = new string[columns]; for(int iter = 0 ; iter < columns ; iter++) { columnnames[iter] = cur.getcolumnname(iter); } while(next) { row currentrow = cur.getrow(); string[] currentrowarray = new string[columns]; for(int iter = 0 ; iter < columns ; iter++) { currentrowarray[iter] = currentrow.getstring(iter); } data1.add(currentrowarray); next = cur.next(); } object[][] arr = new object[data1.size()][]; data1.toarray(arr); } } }catch(ioexception e){ e.printstacktrace(); } for(k = 0 ; k< data1.size(); k++){ log.p(data1.get(k)[0]); } if(k>0){ //cal.setuiid("calendarselectedday"); } } /* @override protected boolean isinitialized(){ boolean result = false; log.p("isinitialised"); return result; }*/ public customised(){ } @override protected button createday() { button day = new button(); day.setalignment(center); day.setuiid("calendarday1"); day.setendswith3points(false); day.settickerenabled(false); return day; } }
and expected result be:-
that's because placed code inside actionperformed method triggered upon button pressed/released. move code updatebuttondaydate scope
Comments
Post a Comment