B4J Question DatePicker behaviour differs between Oracle Java 8 and OpenJDK 11?

walt61

Active Member
Licensed User
Longtime User
When editing the 'textfield' (for want of a better word) of the DatePicker, I see the following happening when the view loses focus or when Enter is pressed:
- compiled with Oracle Java 8: the ValueChanged event fires
- compiled with OpenJDK 11: the event doesn't fire, so the text shows the edited value but the actual value is still the original one, which is of course confusing

Clicking the calendar button does fire ValueChanged in both versions.

I remedied it by unchecking the 'Editable' property in the Designer, but wonder if this is a bug or if there is a way to make the 11 version behave like the 8 one?
 

Attachments

  • testDatePicker.zip
    2.1 KB · Views: 161

Erel

B4X founder
Staff member
Licensed User
Longtime User
Confirmed (Enter does work but lose focus doesn't). It looks like a bug in JavaFX.

Add this code:
B4X:
Private Sub DatePicker1_FocusChanged (HasFocus As Boolean)
    If HasFocus = False Then
        Dim s As String = DatePicker1.As(JavaObject).RunMethodJO("getEditor", Null).RunMethod("getText", Null)
        Try
            Dim date As Long = DateTime.DateParse(s)
            DatePicker1.DateTicks = date
        Catch
            DatePicker1.As(JavaObject).RunMethodJO("getEditor", Null).RunMethod("setText", Array(DateTime.Date(DatePicker1.DateTicks)))
        End Try
    End If
End Sub
 
Upvote 0
Top