Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default value for javafx DatePicker in FXML?

Is it possible to initialize default value for DatePicker at FXML level?

<children>
            <DatePicker fx:id="datePicker" value="2015-07-20"/>
            <Label fx:id="messageLabel" textAlignment="JUSTIFY" />
</children>

Obviously that throws an exception, Is it possibly to call constructor of LocalDate?

For example:

        <DatePicker fx:id="datePicker" value="LocalDate.of(2015,07,20)"/>
like image 342
Palcente Avatar asked Oct 31 '25 15:10

Palcente


1 Answers

You can set default value of the date to today through controller. Following line worked for me.

datePicker.setValue(LocalDate.now());
like image 185
venki Avatar answered Nov 02 '25 05:11

venki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!