简体   繁体   English

java swing使用日期的最佳方法是什么

[英]what is the best way to use dates with java swing

what i want to do is having like the java script popup date chooser in my application. 我想做的就是在我的应用程序中使用Java脚本弹出日期选择器。 i am using java swing and would like to avoid any input mistakes by the user. 我正在使用Java swing,并希望避免用户输入错误。 specifying a format is easy to implement but not user friendly for the user. 指定格式很容易实现,但对用户不友好。 what are your suggestion ? 你有什么建议? any libraries? 有图书馆吗?

There are a number of date picker libraries for Swing. 有很多用于Swing的日期选择器库。

I have used the JXDatePicker from SwingX and JCalendar in the past. 我过去曾使用过SwingXJCalendar的JXDatePicker

Use a date picker, like JCalendar or JDatePicker . 使用日期选择器,例如JCalendarJDatePicker Since users can't type raw date strings, you don't have to worry about their mistakes. 由于用户无法键入原始日期字符串,因此您不必担心他们的错误。

Edit: drhorrible is right. 编辑:可怕的是正确的。 I've fixed the link now. 我已经修复了链接。

There was a commercial product called JDatePicker (I see this domain is now parked), the open source project which I started in 2004 with the same name has no relation to it. 有一个名为JDatePicker的商业产品(我看到此域现在已停放),我于2004年启动的同名开源项目与此无关。 I not 100% sure who had the name first, but it seems like the former is no longer available. 我不确定100%是谁的名字,但似乎前者不再可用。

You can find the open source JDatePicker on GitHub or SourceForge. 您可以在GitHub或SourceForge上找到开源JDatePicker The open source project will stay active as long as someone will need it. 只要有人需要,开源项目就会保持活动状态。

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

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