|
|
@ -26,7 +26,7 @@ public class JDateDocument extends PlainDocument{ |
|
|
|
** 调用者:类JDateDocument |
|
|
|
** 调用者:类JDateDocument |
|
|
|
*******************************************************************/ |
|
|
|
*******************************************************************/ |
|
|
|
public JDateDocument(JTextComponent tc, SimpleDateFormat dateFormat) throws |
|
|
|
public JDateDocument(JTextComponent tc, SimpleDateFormat dateFormat) throws |
|
|
|
UnsupportedOperationException { |
|
|
|
UnsupportedOperationException{ |
|
|
|
//当前日期构造
|
|
|
|
//当前日期构造
|
|
|
|
this(tc, dateFormat, getCurrentDate(dateFormat)); |
|
|
|
this(tc, dateFormat, getCurrentDate(dateFormat)); |
|
|
|
} |
|
|
|
} |
|
|
@ -34,14 +34,15 @@ public class JDateDocument extends PlainDocument{ |
|
|
|
public JDateDocument(JTextComponent tc, |
|
|
|
public JDateDocument(JTextComponent tc, |
|
|
|
SimpleDateFormat dateFormat, |
|
|
|
SimpleDateFormat dateFormat, |
|
|
|
String initDateTime) throws |
|
|
|
String initDateTime) throws |
|
|
|
UnsupportedOperationException { |
|
|
|
UnsupportedOperationException{ |
|
|
|
//设置当前日期格式
|
|
|
|
//设置当前日期格式
|
|
|
|
setDateFormat(dateFormat); |
|
|
|
setDateFormat(dateFormat); |
|
|
|
//保存操作的文本框
|
|
|
|
//保存操作的文本框
|
|
|
|
textComponent = tc; |
|
|
|
textComponent = tc; |
|
|
|
try { |
|
|
|
//设置显示为当前日期,同时完成显示的格式化
|
|
|
|
|
|
|
|
try{ |
|
|
|
insertString(0, initDateTime, null); |
|
|
|
insertString(0, initDateTime, null); |
|
|
|
} catch (BadLocationException ex) { |
|
|
|
} catch(BadLocationException ex){ |
|
|
|
throw new UnsupportedOperationException(ex.getMessage()); |
|
|
|
throw new UnsupportedOperationException(ex.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|