📄 tcalendarpopup.java
字号:
/**
* 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);
}
/**
* 设置指定的日期
* @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);
}
}
}
/**
* 选定的日期 触发的事件
*/
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 ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -