B4J Library jAnotherDatePicker (class)

SS-2016-03-02_10.18.59.png


This is a date picker similar to B4A AnotherDatePicker.

In order to use it in your project, you should choose Project - Add existing module and add jAnotherDatePicker to your project. You should also add the DatePicker layout file and calendar_icon.png.

It is implemented as a custom view. It should be added from the designer.
 

Attachments

  • jAnotherDatePicker.zip
    6.8 KB · Views: 961
Last edited:

tdocs2

Well-Known Member
Licensed User
Longtime User
Greetings.

Thank you for your replies to this Newbie question.

1. I am using the Open Designer for my app. I do not have any FXML layouts.
2. When I click on Designer, Scene Builder Layouts, it gives me one Choice - Create New.
3. As instructed,
You should also add the DatePicker layout file.
.
How do I add the DatePicker layout file to my project?

Obviously, I was able to add the jAnotherDatePicker module to the project.

Thanks again.

Sandy
 

tdocs2

Well-Known Member
Licensed User
Longtime User
Thank you, Erel.

I followed your instructions, and I received the error below. My app is looking for DatePicker.bjl and not for DatePicker.fxml... I do not know how to tell my app to look for the fxml (which is in the Files Folder). That was my poorly worded question in the post above.

B4X:
Program started.
janotherdatepicker._initialize (java line: 269)
java.io.FileNotFoundException: DatePicker.bjl
    at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:180)
    at anywheresoftware.b4j.objects.LayoutBuilder.loadLayout(LayoutBuilder.java:43)
    at anywheresoftware.b4j.objects.PaneWrapper.LoadLayout(PaneWrapper.java:76)
    at b4j.example.janotherdatepicker._initialize(janotherdatepicker.java:269)
    at b4j.example.main._appstart(main.java:57)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
    at b4j.example.main.start(main.java:36)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherImpl.java:863)
    at com.sun.javafx.application.LauncherImpl$$Lambda$53/10423575.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl$$Lambda$45/1681433494.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
    at com.sun.javafx.application.PlatformImpl$$Lambda$48/1334252076.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
    at com.sun.javafx.application.PlatformImpl$$Lambda$47/1685538367.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$145(WinApplication.java:101)
    at com.sun.glass.ui.win.WinApplication$$Lambda$36/2058534881.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)
 

tdocs2

Well-Known Member
Licensed User
Longtime User
You need to add DatePicker.fxml file from the zip file to your project Files tab.

I GOT IT!

Add MEANS In Project Files Tab > Add File - not just copy the fxml to the Files folder.

Thank you, Erel, for your patience :):):cool: (in FL, USA, you need sunglasses)
 

ivan.tellez

Active Member
Licensed User
Longtime User
I GOT IT!

Add MEANS In Project Files Tab > Add File - not just copy the fxml to the Files folder.

Thank you, Erel, for your patience :):):cool: (in FL, USA, you need sunglasses)


Actualy you can "just copy" the fxml to the Files folder. Then, click on the "Sync" Button in the Files Tab.
 

le_toubib

Active Member
Licensed User
Longtime User
hi all
after adding the module and the layout file
i get this error :

Program started.
Error occurred on line: 81 (Main)
java.lang.ClassCastException: b4j.example.janotherdatepicker cannot be cast to anywheresoftware.b4a.ObjectWrapper
at anywheresoftware.b4j.objects.FXMLBuilder.setNodeField(FXMLBuilder.java:140)
at anywheresoftware.b4j.objects.FXMLBuilder.LoadLayout(FXMLBuilder.java:124)
at anywheresoftware.b4j.objects.PaneWrapper.LoadLayout(PaneWrapper.java:76)
at b4j.example.main._appstart(main.java:383)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:607)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:228)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.start(main.java:36)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)

at the line of this code 81: MainForm.RootPane.LoadLayout("lo2") 'Load the layout file.

B4X:
        MainForm = Form1
        CurrentState = "Initiating"
        MainForm.Initialize("mainform",-1,-1)
        MainForm.SetFormStyle("DECORATED")
        SetSystemProperty("glass.accessible.force", "false")
        MainForm.RootPane.LoadLayout("lo2") 'Load the layout file.
        MainForm.Show
       dp_pt_spn_dob.Initialize(MainForm)

what am i doing wrong ?

p.s :
i also get this worning from the downloaded project itself : this sub should be used for variable declarations or assignemnts of primitive values
a this line :
Private selectedColor As Paint = fx.Colors.RGB(144, 176, 248)
 

le_toubib

Active Member
Licensed User
Longtime User
Ok , i restarted everything, and now it's working , with the same worning though.
But when i moved to another device, i get another error, upon clicking on the text field the date picker starts to appear and then the app crash ;
Java(TM) platform SE has stopped working
BEX64
 
Last edited:

le_toubib

Active Member
Licensed User
Longtime User
I found both 1.fxml and datepicker.Fxml can be opened in scene builder?
My original (very big) layout file was created in scene builder.
Why is it working perfectly on one device? And the whole java.exe crashes on another ?
 

le_toubib

Active Member
Licensed User
Longtime User
You wonna say to create a pane inside my layout in scene builder.
And then load the pane with the datepicker. Fxml layout?
Should the pane be invisible at first?
What about the .Show property?
 

le_toubib

Active Member
Licensed User
Longtime User
OK :
for some reason i had an older version of adp with fxml not bjl...

now what i did :
1- i created i new layout dp.bjl inside which i created the custom view "AnotherDatePicker"
2- i have my original lo2.fxml , inside which i added a pane node , then i loadlayout("dp") for this new node
3- in the project it shows correctly and when i press on the icon the datepicker is shown correctly
4- but the AnotherDatePicker_DateChanged (NewDate As Long) event is not raised when the date is changed

EDIT :

sorry that was a mistake in naming the view ..
now working fine.
but had to set a boolean variable to prevent the trigger of the event before changing the date ( as it s triggered on show)
 
Last edited:

le_toubib

Active Member
Licensed User
Longtime User
Alright everything it's working fine on my win 10 laptop ... But when i moved to win 7 desktops the whole app crash at the line ;

Frm.showandwait

In the class module
Is there any explanation ?
 

roberto64

Active Member
Licensed User
Longtime User
regardsErnel hello, how can I display any Another DATEPICKER1 a different date es. (AnotherDatePicker1.Date = m.Get ("datapreventivo"), he writes in AnotherDatePicker1.
 
Top