简体   繁体   English

将DateFormatter与JFormattedTextField一起使用

[英]Using a DateFormatter with a JFormattedTextField

I am using a JFormattedTextField in combination with a DateFormatter . 我将JFormattedTextFieldDateFormatter结合使用。 I've seen examples of this kind of text field using MaskFormatter in which a user can type in values and overwrite existing ones (eg the placeholder characters) without having to erase them manually. 我已经看到了使用MaskFormatter的这种文本字段的示例,其中用户可以键入值并覆盖现有的值(例如,占位符),而无需手动擦除它们。 Is it possible to do the same thing with a DateFormatter ? 是否可以用DateFormatter做同样的事情? For example, I want to use 00:00:00 as the placeholder string, and the time should be in the format HH:mm:ss . 例如,我想使用00:00:00作为占位符字符串,并且时间应采用HH:mm:ss格式。

JFormattedTextField相比, JSpinner对于Date实例来说是更好,更好的JComponent ,我认为它更加舒适直观

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM