dear all,
in the below codes, i do not know how to set different colors for rows with the different months and setting a same color for rows with the same month.
A simple illustration here:
-----Row-------Month--------Color of Row
-------0---------Jan-------------Green
-------1---------Jan-------------Green
-------2---------Feb-------------Blue
-------3---------Mar-------------Green
-------4---------Mar-------------Green
-------5---------Apr--------------Blue
-------6---------Apr--------------Blue
sorry for my weak programming knowledge, hope for forgiveness from all...
Thank you.
Codes:
public void rowColor() {
int checkMonth, theMonth;
Date checkDate, theDate;
checkDate = new Date();
theDate = new Date();
//getting the date in first row
checkDate = (Date)m_data.getValueAt(0,1);
//getting month in the first row
checkMonth = checkDate.getMonth();
for(int i=1; i<m_data.getRowCount(); i++ ) {
//getting the date and month in subsequent rows
theDate = (Date)m_data.getValueAt(i,1);
theMonth = theDate.getMonth();
//Comparing the month information labelled in different rows
if( theMonth == checkMonth ) {
//if the rows are labelled with the same month
//set the same row color
}
else {
//set the row to another color if month information is found to be different
}
checkMonth = theMonth;
}
}