?日期的要求要簡單一點,
1:支持動態布局。
2:支持任意星期開始,不同的星期開始值會影響日期開始的行列位置。
整體效果請看上一篇文章
打造完美SWT日期選擇控件:(六)星期的截圖。
3:能監聽到用戶雙擊事件。并處理。
關鍵代碼如下
????private?void?setDays()?{
????????clearDays();
????????Calendar?cal?=?(Calendar)?basicCalendar.clone();
????????int?today?=?cal.get(Calendar.DAY_OF_MONTH);
????????int?thisMonth?=?cal.get(Calendar.MONTH);
????????cal.set(Calendar.DAY_OF_MONTH,?1);
????????int?week?=?cal.get(Calendar.DAY_OF_WEEK);
????????week?-=?this.firstDayOfWeek;
????????for?(int?i?=?week;?i?<?days.length;?cal.add(Calendar.DAY_OF_MONTH,?1))?{
????????????Label?label?=?days[i++];
????????????int?day?=?cal.get(Calendar.DAY_OF_MONTH);
????????????int?month?=?cal.get(Calendar.MONTH);
????????????if?(month?==?thisMonth)?{
????????????????if?(day?==?today)?{
????????????????????label.setForeground(getDisplay().getSystemColor(SWT.COLOR_DARK_RED));
????????????????}
????????????????label.setText(Integer.toString(cal.get(Calendar.DAY_OF_MONTH)));
????????????????label.setData(label.getText());
????????????????label.addListener(SWT.MouseDoubleClick,?this);
????????????}?else?{
????????????????return;
????????????}
????????}
????}
posted on 2006-12-29 11:26
交口稱贊 閱讀(3669)
評論(0) 編輯 收藏 所屬分類:
Eclipse RCP SWT