I am new to Java and I have started developing applications in java using javaFx. searched a lot but couldn't find any date and time picker in javaFx. Even i tried JFxtras but its not working. By the way i am using javafx 2.2.3 and java 7. Any help would be highly appreciated.
相关问题
- I get an exception when trying to swap elements in
- JFX scale image up and down to parent
- Dragging an undecorated Stage in JavaFX
- JavaFX sample issue
- How to resize datepicker text programmatically
相关文章
- Woocommerce update shipping methods in checkout vi
- jQuery UI datepicker - Trying to capture click eve
- Low quality icon in taskbar of a Stage. JavaFX
- Loading custom font using JavaFX 8 and css
- How do I correctly capture Materialize-CSS datepic
- Javafx Platform.runLater never running
- JavaFX scrolling table update performance degrades
- Javafx select multiple rows
I find it most convenient to enter the time via the keyboard instead of changing it with sliders. It's quite easy to extend the included DatePicker to look like this:
I also find it annoying that the DatePicker doesn't commit the edited value in the TextField onblur, so the following code fixes that as well.
The snippet is written in Kotlin for brevety, you can easily convert it to Java via IntelliJ IDEA:
Bind your LocalDateTime property to the dateTimeValueProperty.
Slightly "improved" (at least for my needs) version that works with NullableTimeStamp... in order to be able to, well, null it (for ease with MySQL)...
Dunno if this can help anyone but here it is:
NullableTimeStamp:
and DateTimePicker:
It basically masks the 0L Timestamp value as if it was NULL... hope this can help cheers
Here is a Java version of the DateTimePicker control above, slightly improved.
This code is now part of TornadoFX Controls and you can have a look at the latest version of DateTimePicker.java in the GitHub Repo. The control is available in Maven Central as well under these coordinates:
The implementation right now:
The
dateTimeValue
property contains the value with time, and thevalueProperty
contains only the date value.I have not added tests for this component yet, so the implementation might change, check GitHub for the latest version.
JFXtras project has a working version for JavaFX 2.2. Look for
CalendarPicker
,CalendarTimePicker
, ... at the repo, under the 2.2 branch.You can test it by downloading the lastest release (2.2-r6-SNAPSHOT) from jfxtras.org.
This short snippet will create a calendar for picking both date and time: