문제

I am developing a simple desktop application with Java and NetBeans 7 I have a textfield and a textarea as well as a jxdatepicker I have a CLEAR button that is suppose to clear the fields when needed

I use the

jtextfield.setText("") and 
  jtextArea.setText("")

to clear the textfield and textarea as indicated. but my problem is that how do I clear the date picker to present a clean field when the clear button is clicked?

도움이 되었습니까?

해결책

basically:

picker.setDate(null);

Addendum:

digging into the internals of the picker and setting the text of its editor is wrong because the text is only updated in the editor but not committed to the underlying model:

picker.getEditor().setText("");
System.out.println(picker.getDate());

// output
Thu Feb 28 00:00:00 CET 2013 

// output after nulling the date with the appropriate api
null

다른 팁

1.Set property like this. datePicker.getModel().setValue(null);;

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top