JCalendar 获取日期
在我的项目中,我使用 com.toedter.calendar.JCalendar 类。但我不知道选择日期后如何获取日期。
JDateChooser和JXDatePicker满足了我的需求。当从 JDateChooser 选择日期时,有一个代码提供日期。
JDateChooser picker=new JDateChooser();
picker.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
setDate(picker.getDate());
}
});
In my project I am using com.toedter.calendar.JCalendar
class. But I do not know how can I get date when date is chosen.
JDateChooser and JXDatePicker met my need. There is a code that provides date when a date is chosen from JDateChooser.
JDateChooser picker=new JDateChooser();
picker.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
setDate(picker.getDate());
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您肯定需要
addPropertyChangeListener()
,但您需要检查getNewValue()
。有一个很好的例子You definitely want
addPropertyChangeListener()
, but you need to checkgetNewValue()
. There's a good example here.我对这门课不熟悉。但我尝试过 SwingX , JXDatePicker 非常棒。哪个应该做你想做的事。
在这里您可以看到JXDatePicker 简介,其中有漂亮的图像显示其功能等。
PS:尝试向我们提供您课程的链接,以便有人可以查看。
祝一切顺利,博罗。
I am not familiar with this class. But I have tried SwingX were is fantastic JXDatePicker. Which should do what you want.
Here you can see introduction to the JXDatePicker where are nice images showing its capability etc.
PS: Try to provide us with a link to your class then someone can take a look at it.
All the best, Boro.
我自己没有使用过它,但根据javadoc:
http: //www.toedter.com/en/jcalendar/api/com/toedter/calendar/JCalendar.html
似乎有一个 getDate() 方法。这行不通?
Have not used it myself, but according the javadoc:
http://www.toedter.com/en/jcalendar/api/com/toedter/calendar/JCalendar.html
there seems to be a getDate() method. Does not this work?
您尝试过 getDate() 方法吗?我认为这会让你所要求的任务变得容易。
Have you tried getDate() method ? I think it will easy your requested mission.