private void buildMonthsList(cmbMonth monthsList) {
for (int monthCount = 0; monthCount < 12; monthCount++)
monthsList.addItem(Const.MONTHS[monthCount]);
}
public boolean DaysComboBox (int year)
{
Calendar cal = Calendar.getInstance();
int months = cal.get(Calendar.MONTH);
year = (int) cmbYear.getSelectedItem();
boolean leap = false;
if(year % 4 == 0)
{
if( year % 100 == 0)
{
// year is divisible by 400, hence the year is a leap year
if ( year % 400 == 0)
{
leap = true;
}
else {
leap = false;
}
}
else {
leap = true;
}
}
else {
leap = false;
}
return leap;
}
I need some help with a Java Swing program I have for school which is important.
How can you fill in the number of days according to the month and year including leap year? I used 3 separate combo boxes, one for the days, another one for the months and another for the years. It should also be called from a method.
See Question&Answers more detail:os