?? tcalendarpopup.java
字號(hào):
/**
* package com.mc.tables.client;
*/
package com.mc.tables.client;
/**
* import lib
*/
import java.util.Date;
import com.google.gwt.core.client.JavaScriptException;
import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* class TCalendarPopup
* @author Administrator
* 可隱藏日歷
*/
public class TCalendarPopup extends PopupPanel implements ChangeListener{
final Calendar calendar = new Calendar();
private String selectDate = "";
private String sep = "-";
public TCalendarPopup(){
super();
this.add(calendar);
calendar.addChangeListener(this);
}
/**
* 設(shè)置指定的日期
* @param date 日期字符串 如"2007-5-5" "2007/5/"
* @param ot 日期字符串的分隔符 如"-" "/"
*/
public void setDate(String date,String ot){
if(date != ""){
int y =1982;
int m =6;
int d= 6;
sep =ot;
try{
String ds =date;
int i = ds.indexOf(ot);
String sy=ds.substring(0,i);
y = Integer.parseInt(sy);
ds=ds.substring(i+1);
int j = ds.indexOf(ot);
String sm = ds.substring(0,j);
m = Integer.parseInt(sm);
ds = ds.substring(j+1);
String sd = ds;
d = Integer.parseInt(sd);
}
catch(JavaScriptException js){
js.fillInStackTrace();
}catch(Exception e){
e.fillInStackTrace();
}finally{
calendar.setYearMonth(y, m-1, d);
}
}
}
/**
* 選定的日期 觸發(fā)的事件
*/
public void onChange(Widget sender) {
// TODO Auto-generated method stub
selectDate = (calendar.getDate().getYear()+1900) +sep+(calendar.getDate().getMonth()+1)+sep+calendar.getDate().getDate();
this.hide();
}
/**
* 獲得選定的日期
* @return 選定的日期
*/
public String getSelectedDate(){
return selectDate ;
}
/**
* 獲得選定的月份
* @return 選定的月份
*/
public String getSelectedMonth(){
String ms =selectDate;
if(ms != ""){
ms=ms.substring(0, ms.lastIndexOf(sep));
}
return selectDate ;
}
/**
* 獲得選定的年份
* @return 選定的年份
*/
public String getSelectedYear(){
String ms =selectDate;
if(ms != ""){
ms=ms.substring(0, ms.indexOf(sep));
}
return ms ;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -