B4J Library Persian Date Picker View (Independent from B4XView)

Hi everybody.
This is a Persian date picker I wrote. It doesn't use B4XView and has no special requirements.
Displaying the date picker pop-up is done with code. It works as a ResumableSub.

To use it:
1. simply add "PerPicker.bas" to your project;
2. Provide its main function with a parent node and an (x, y);
3. "Wait For" it till it returns the result once the date is picked.

I've attached a very simple sample usage code with it. The top part of the code and some other parts are also commented. Refer to them for more details if needed.

UPDATE: The calendar now shows today's date by putting a black border around it.
 

Attachments

  • Persian DatePicker.zip
    5.4 KB · Views: 216
Last edited:

behnam_tr

Active Member
Licensed User
B4X:
Waiting for debugger to connect...
Program started.
1399/8/13
Unexpected event (missing RaiseSynchronousEvents): day_mouseexited
java.lang.Exception: Stack trace
    at java.lang.Thread.dumpStack(Thread.java:1336)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:199)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
    at anywheresoftware.b4j.objects.NodeWrapper$7.handle(NodeWrapper.java:176)
    at anywheresoftware.b4j.objects.NodeWrapper$7.handle(NodeWrapper.java:1)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.event.Event.fireEvent(Event.java:198)
    at com.sun.javafx.event.EventQueue.fire(EventQueue.java:48)
    at javafx.scene.Scene$MouseHandler.handleNodeRemoval(Scene.java:3598)
    at javafx.scene.Scene$MouseHandler.access$7600(Scene.java:3485)
    at javafx.scene.Scene.generateMouseExited(Scene.java:3482)
    at javafx.scene.Parent$2.onProposedChange(Parent.java:487)
    at com.sun.javafx.collections.VetoableListDecorator.remove(VetoableListDecorator.java:329)
    at com.sun.javafx.collections.VetoableListDecorator.remove(VetoableListDecorator.java:221)
    at anywheresoftware.b4j.objects.NodeWrapper.RemoveNodeFromParent(NodeWrapper.java:355)
    at b4j.example.perpicker._toppane_animationcompleted(perpicker.java:889)
    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:498)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA$1.run(BA.java:216)
    at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
    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$4(WinApplication.java:186)
    at java.lang.Thread.run(Thread.java:748)
(RuntimeException) java.lang.RuntimeException: Object should first be initialized (Label).


i get this error when change month and select any day

plz add today button
plz Highlighting today's date on the days panel
 

MegatenFreak

Active Member
Licensed User
B4X:
Waiting for debugger to connect...
Program started.
1399/8/13
Unexpected event (missing RaiseSynchronousEvents): day_mouseexited
java.lang.Exception: Stack trace
    at java.lang.Thread.dumpStack(Thread.java:1336)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:199)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
    at anywheresoftware.b4j.objects.NodeWrapper$7.handle(NodeWrapper.java:176)
    at anywheresoftware.b4j.objects.NodeWrapper$7.handle(NodeWrapper.java:1)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.event.Event.fireEvent(Event.java:198)
    at com.sun.javafx.event.EventQueue.fire(EventQueue.java:48)
    at javafx.scene.Scene$MouseHandler.handleNodeRemoval(Scene.java:3598)
    at javafx.scene.Scene$MouseHandler.access$7600(Scene.java:3485)
    at javafx.scene.Scene.generateMouseExited(Scene.java:3482)
    at javafx.scene.Parent$2.onProposedChange(Parent.java:487)
    at com.sun.javafx.collections.VetoableListDecorator.remove(VetoableListDecorator.java:329)
    at com.sun.javafx.collections.VetoableListDecorator.remove(VetoableListDecorator.java:221)
    at anywheresoftware.b4j.objects.NodeWrapper.RemoveNodeFromParent(NodeWrapper.java:355)
    at b4j.example.perpicker._toppane_animationcompleted(perpicker.java:889)
    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:498)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA$1.run(BA.java:216)
    at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
    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$4(WinApplication.java:186)
    at java.lang.Thread.run(Thread.java:748)
(RuntimeException) java.lang.RuntimeException: Object should first be initialized (Label).


i get this error when change month and select any day

plz add today button
plz Highlighting today's date on the days panel
You're welcome Behnam;) I was hoping someone else would find it useful!
I've updated the code. Now it shows today's date, as you suggested, which is very useful indeed! Maybe I'll add a today button as well, though the current view doesn't have a suitable space for it. If I ever do add it, I'll update it here.
As for the error you mentioned, it only happens when you run in DEBUG mode. In release mode, you don't even get a warning. That's strange. Maybe following Erel's suggestion would help. But I always run in release mode anyway!
 
Last edited:

behnam_tr

Active Member
Licensed User
hi
i have problem in little forms
check image
sample attached

in my project i cant decrease form size and also form must start as a modalform(with showandwait method)

how cant i solve this ??
thanks

Untitled222.png
 

Attachments

  • perdatepick.zip
    7.3 KB · Views: 125

MegatenFreak

Active Member
Licensed User
hi
i have problem in little forms
check image
sample attached

in my project i cant decrease form size and also form must start as a modalform(with showandwait method)

how cant i solve this ??
thanks

View attachment 95813
Hi. I fixed your size problem by editing the perpicker module in your code. Now you can pass it a "cell_height" parameter. The cell height was 30 in the default module. You can pass a smaller number to reduce the height and make the calendar smaller. In your code, for example, I set cell height to 22, and now it fits the small form perfectly. Here's a screenshot:
Untitled.png


and here's your edited code:
I hope this helps;)
 

Attachments

  • perpicker-small.zip
    7.3 KB · Views: 136
Top