0

When I make the jDateChooser.requestFocusInWindow() the cursor goes to the end of the date field, I want the cursor to be set at the beginning, the function setCaretPosition(0) does not work in this case. How can I set the cursor at the beginning of the field?

thanks,

jm

Jens
  • 67,715
  • 15
  • 98
  • 113

1 Answers1

0

In the constructor of JDateChooser , you may specify the IDateEditor to use.

In your case JTextFieldDateEditor (which is probably the default one) looks good.

Once you have your editor, just call setCaretPosition(0) on it .

Example :

JTextFieldDateEditor editor = new JTextFieldDateEditor();

JDateChooser dateChooser = new JDateChooser(editor);
dateChooser.setDate(new Date());

editor.setCaretPosition(0);
Arnaud
  • 17,229
  • 3
  • 31
  • 44