有没有选项JTEXTFIELD可以检查特定格式的输入吗?
我想使用JTEXTFIELD以YYYY-MM-DD格式输入日期。是否有可能验证输入格式?
I want to use a JTextField to enter dates in the YYYY-MM-DD format. Is there a possibility to validate the entered format?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在询问输入验证。使用事件侦听器自己执行此操作,该事件侦听器
使用哪种机制,取决于您想要提供的速度以及验证的代价高昂。
作为替代方案,您可以参考。
You are asking about Input Validation. Do this yourself with an event listener that is triggered
Which mechanism you use depends on how quickly you want to give feedback and how costly a validation is.
As an alternative you can refer to the Swing Frameworks Input Validation features.