advancing
发贴: 1
积分: 0
|
于 2009-11-05 21:53
private void JComboBoxMonthItemStateChanged(java.awt.event.ItemEvent evt) { // TODO add your handling code here: leap=YEAR%4==0&&YEAR%100!=0||YEAR%400==0; month=(String)JComboBoxMonth.getSelectedItem(); if(month.startsWith("4")||month.startsWith("6")||month.startsWith("9")||month.startsWith("11")) { JComboBoxDay.removeItem("31"); } else if((!leap)&&month=="2") { JComboBoxDay.removeAllItems(); JComboBoxDay.addItem("26"); JComboBoxDay.addItem("27"); JComboBoxDay.addItem("28"); JComboBoxDay.addItem("29"); JComboBoxDay.addItem("30"); JComboBoxDay.addItem("31"); JComboBoxDay.removeItem("31"); JComboBoxDay.removeItem("30"); JComboBoxDay.removeItem("29"); } else if(month.startsWith("1")||month.startsWith("3")||month.startsWith("5")||month.startsWith("7")||month.startsWith("8")||month.startsWith("10")||month.startsWith("12")) { JComboBoxDay.removeAllItems(); JComboBoxDay.addItem("26"); JComboBoxDay.addItem("27"); JComboBoxDay.addItem("28"); JComboBoxDay.addItem("29"); JComboBoxDay.addItem("30"); JComboBoxDay.addItem("31"); } else if((leap)&&month=="2") { JComboBoxDay.removeAllItems(); JComboBoxDay.addItem("26"); JComboBoxDay.addItem("27"); JComboBoxDay.addItem("28"); JComboBoxDay.addItem("29"); JComboBoxDay.addItem("30"); JComboBoxDay.addItem("31"); JComboBoxDay.removeItem("31"); JComboBoxDay.removeItem("30"); } } private void JComboBoxYearItemStateChanged(java.awt.event.ItemEvent evt) { // TODO add your handling code here: year=(String)JComboBoxYear.getSelectedItem(); YEAR=Integer.parseInt(year); }
无论YEAR取什么值都执行 else if((leap)&&month=="2")分支 当注释 else if((leap)&&month=="2")分支时执行else if((!leap)&&month=="2")分支
|