B4J Question Datepicker in internal designer

upsis

Member
Licensed User
Longtime User
How do I implement datepicker in internal designer? I tried using jrldatepicker and others but they use scene buider.
 

rwblinn

Well-Known Member
Licensed User
Longtime User
As a workaround you could use a JavaObject. Example:

B4X:
'Create a datepicker and add to the mainform
'Define JavaObject (requires JavaObject Library) Private joDatePicker As JavaObject
'Reference:http://javafx.scene.control.DatePicker
Sub CreateDatePicker
    'Init the datepickerobject
      joDatePicker.InitializeNewInstance("javafx.scene.control.DatePicker", Null)
      MainForm.RootPane.AddNode(joDatePicker, 0, 0, -1, -1)
    'Set some properties
    joDatePicker.RunMethod("setShowWeekNumbers", Array As Object(True))
    'Set actual date
    Dim joLD As JavaObject
    joLD.InitializeStatic("java.time.LocalDate")
    joDatePicker.RunMethod("setValue", Array As Object(joLD.RunMethod("now", Null)))                                                                                                             
End Sub

'Get the selected datevalue and add to a label view
Sub ButtonDatePicker_Action
    LabelDatePicker.Text = joDatePicker.RunMethod("getValue", Null)
End Sub
 
Upvote 0
Top