欢迎来到天天文库
浏览记录
ID:38226252
大小:36.56 KB
页数:14页
时间:2019-06-07
《swing日期控件》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Swing日期控件一、截图:二、源代码:packagecom.longtu.rpt.app.view.rptview.multisheet;importjava.util.Calendar;importjavax.swing.JComboBox;importjavax.swing.JTable;importjavax.swing.table.DefaultTableModel;publicclassDateChoiceActive{//初始化年选择下拉框publicstaticString[]i
2、nitItemsYear(){String[]arrYear=newString[70];for(inti=1980;i<2050;i++){arrYear[i-1980]=String.valueOf(i);}returnarrYear;}//初始化月选择下拉框publicstaticvoidinitItemsMonth(JComboBoxcmbMonth){cmbMonth.addItem("一月");cmbMonth.addItem("二月");cmbMonth.addItem("三月")
3、;cmbMonth.addItem("四月");cmbMonth.addItem("五月");cmbMonth.addItem("六月");cmbMonth.addItem("七月");cmbMonth.addItem("八月");cmbMonth.addItem("九月");cmbMonth.addItem("十月");cmbMonth.addItem("十一月");cmbMonth.addItem("十二月");}publicstaticStringinitComboboxSelected(
4、intmonth){if(1==month){return"一月";}elseif(2==month){return"二月";}elseif(3==month){return"三月";}elseif(4==month){return"四月";}elseif(5==month){return"五月";}elseif(6==month){return"六月";}elseif(7==month){return"七月";}elseif(8==month){return"八月";}elseif(9==mo
5、nth){return"九月";}elseif(10==month){return"十月";}elseif(11==month){return"十一月";}else{return"十二月";}}publicstaticintgetSelectItemValue(Stringmonth){if("一月".equals(month)){return1;}elseif("二月".equals(month)){return2;}elseif("三月".equals(month)){return3;}el
6、seif("四月".equals(month)){return4;}elseif("五月".equals(month)){return5;}elseif("六月".equals(month)){return6;}elseif("七月".equals(month)){return7;}elseif("八月".equals(month)){return8;}elseif("九月".equals(month)){return9;}elseif("十月".equals(month)){return10;
7、}elseif("十一月".equals(month)){return11;}elseif("十二月".equals(month)){return12;}return0;}privatestaticintgetCurrentMonthFirstDay(intyear,intmonth){Calendarnow=Calendar.getInstance();now.set(year,month-1,1);intweek=now.get(Calendar.DAY_OF_WEEK)-1;returnw
8、eek;}privatestaticintgetCurrentMonthDays(intyear,intmonth){intdays=0;//存储当月的天数booleanisRn=false;//是否闰年for(inti=1900;i9、10、i%400==0){isRn=true;}else{}}for(inti=1;i<=month;i++){switch(i){case1:case3:case5:case7:case8:case1
9、
10、i%400==0){isRn=true;}else{}}for(inti=1;i<=month;i++){switch(i){case1:case3:case5:case7:case8:case1
此文档下载收益归作者所有