如何清除JDateChooser字段? [英] how to clear JDateChooser field?

查看:98
本文介绍了如何清除JDateChooser字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JDateChooser作为JForm中的一个组件。我已经设置了一个JButton,它将此表单上的所有字段重置为空白。我没有使用actionListener或清除方法的问题,但我不确定如何清除JDateChooser组件。

I am using a JDateChooser as a component in a JForm. I have setup a JButton, which resets all of the fields on this form to blank. I do not have issues with the actionListener, or the method for clearing, but instead am unsure how to clear the JDateChooser component.

更具体地说,我想知道如何从日期选择器的JTextField组件中清除Date,使其为空白。

More specifically I am wondering how to clear the Date from the JTextField component of the date chooser, such that it is blank.

此外,我想将此字段设置为清除后的当前日期。

Furthermore, I would like to set this field to the current date after it is cleared.

推荐答案

如果你想清除JDateChooser字段:

If you want to clear the JDateChooser field:

JDateChooser dateChooser = new JDateChooser();
dateChooser.setCalendar(null);

此代码将字段设置为 null

This code will set the field to null.

要将日期设置为今天,您可以使用例如:

To set the date to today you can use for example:

dateChooser.setDate(new Date())

这篇关于如何清除JDateChooser字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆