B4J Question Setcoloranimated Effect

tufanv

Expert
Licensed User
Longtime User
Hello,

In b4i and b4a I can change the color of a panel with setcoloranimated. And than use a timer to revert back to original color again with set color animated. This gives a good effect for reflecting price changes on the screen.
In b4j , what should be done to get a similar effect , that will change the panels color from grey to green or red and revert back to grey again.

Thanks
 

tufanv

Expert
Licensed User
Longtime User
With jXUI library.
B4X:
Dim v As B4XView = YourView
v.SetColorAnimated(...)

B4XView is the future :)

I am getting this error :

B4X:
Waiting for debugger to connect...
Program started.
Error occurred on line: 31 (Main)
java.lang.NumberFormatException: For input string: "0x888888ff"
    at sun.misc.FloatingDecimal.parseHexString(FloatingDecimal.java:2071)
    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1870)
    at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
    at java.lang.Double.parseDouble(Double.java:538)
    at anywheresoftware.b4a.BA.ObjectToNumber(BA.java:394)
    at b4j.example.main._timertest_tick(main.java:116)
    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:613)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:228)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
    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.BA.raiseEvent2(BA.java:90)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93)
    at anywheresoftware.b4a.objects.Timer$TickTack$1.run(Timer.java:118)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(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$148(WinApplication.java:191)
    at java.lang.Thread.run(Thread.java:748)

when I try with b4j 5.9+ :

B4X:
    Dim v As B4XView=lblprice
    v.SetColorAnimated(1000,fx.Colors.Gray,fx.Colors.Green)
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You don't show what you are actually entering. How are you entering the value? There should be no quotes around it.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Check the method parameters. It expects an Int like in B4A and B4i.

You have two options:
B4X:
v.SetColorAnimated(1000, xui.Color_Gray, xui.Color_Green) 'xui is a global XUI variable.
The second option which is not recommended in this case:
B4X:
v.SetColorAnimated(1000, xui.PaintOrColorToColor(fx.Colors.Gray), xui.PaintOrColorToColor(fx.Colors.Green))
 
Upvote 0
Top