您的位置:首页 > 其它

为日期类型的控件添加focusLost事件

2014-12-31 14:46 211 查看
一、普通日期控件
public void onLoad() throws Exception {
super.onLoad();
//当鼠标在签约日期处失去焦点时,设置到期日期默认为签约日期后1年减一天,如签约日期为2009-1-10,则到期日期就是2010-1-9
this.pksignDate.getEditor().getEditorComponent().addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent e) {
try {
pksignDate_focusLost(e);
if (pksignDate.getValue() != null){
Calendar cal = Calendar.getInstance();
cal.setTime((Date)pksignDate.getValue());
cal.add(Calendar.YEAR,1);
cal.add(Calendar.DAY_OF_MONTH,-1);
pkcontractEndDate.setValue(cal.getTime());
}
} catch(Exception exc) {
handUIException(exc);
}
}
});
}


二、在分录中的日期控件
/**
* @author 胡千好
*/
protected void kdtEntrys_editStopped(KDTEditEvent e) throws Exception {
super.kdtEntrys_editStopped(e);
int row = e.getRowIndex();
int col = e.getColIndex();
//如果是费用开始日期那一列
if(col==2){
if(this.kdtEntrys.getCell(row,col).getValue()!=null){
Calendar cal = Calendar.getInstance();
cal.setTime((Date)this.kdtEntrys.getCell(row,col).getValue());
cal.add(Calendar.YEAR,1);
cal.add(Calendar.DAY_OF_MONTH,-1);
//设置费用结束日期为开始日期后一年
this.kdtEntrys.getCell(row,"feeEndDate").setValue(cal.getTime());
}
}
}




内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐