JFXtras / jfxtras

A supporting library for JavaFX, containing helper classes, extended layouts, controls and other interesting widgets.
http://jfxtras.org
Other
599 stars 123 forks source link

CalendarPicker showTime without Calendar does not display current time #102

Closed DJViking closed 5 years ago

DJViking commented 5 years ago

CalendarPicker does not show time if Calendar is not set

    CalendarPicker picker = new CalendarPicker();
    picker.setShowTime(true);
    picker.setCalendar(Calendar.getInstance());

Without setting Calendar the current date is showing on the CalendarPicker, but not current time.

jfxtras-controls-8.0-r6

tbee commented 5 years ago

I've taken a look and indeed, the time is not initialized. Need to look into this further.

tbee commented 5 years ago

Ok. Interesting. This is as-expected. Let me try to explain.

In your code, with the setCalendar commented out, the picked date is actually null. The date picking part of the UI always shows a month's worth of day buttons, but a date need not be selected (allowNull is true). So what you see are 30 days, today highlighted, but no date selected.

The time picking part always shows a number of sliders, depending on what can be set (hour, minutes, etc), but in the case of a null value they're all left and there is no text. And that is what you see. The sliders need to be present, just like the day buttons, because you need to be able to set a value. The instant you slide a slider, a value is set (you also see that happening in the date when the slider is released).

Try running your code with setAllowNull(false).

So the actual issue here is that "null" is not rendered very clearly in the timepicker. Need to think about how to improve that.

DJViking commented 5 years ago

Not setting a Calendar for CalendarPicker, the shown date and time with setAllowNull(false) are now both showing current date/time.

    CalendarPicker picker = new CalendarPicker();
    picker.setShowTime(true);
    picker.setAllowNull(false);

However with LocalDateTimeTextField, this will not work. java.lang.IllegalArgumentException: Empty string would result in null and that is not allowed

tbee commented 5 years ago

Correct. If allow null is false, then "now" is populated per default.

tbee commented 5 years ago

I've just added showing the empty symbol (Ø) when null is the value in time picker. Nightly build will push that out as 8.0-r7-SNAPSHOT in 20 minutes. Let me know how that works out for you.

DJViking commented 5 years ago

Where can I find this new SNAPSHOT? It is not in Maven central repository.

tbee commented 5 years ago

Snapshots are never in maven central, but in Sonatype's OSS repository. https://oss.sonatype.org/#nexus-search;gav~org.jfxtras~jfxtras-controls~~~~kw,versionexpand