B4J Question How to send Colors through subs?

Midimaster

Active Member
Licensed User
I would like to send a Jfx-Color to a sub where I asign it to a View, but it looks like the type COLORS in not known in the sub. What do I do wrong?


B4X:
'this works:
MyButton.TextColor=jfx.colors.red

'this not:
SendColor(jfx.colors.red)

Sub SendColor(Color as Colors)
    MyButton.TextColor=Color
End Sub
 

Midimaster

Active Member
Licensed User
I already tried also this, but it ends up with a crash
B4X:
Log("Spurrow reset color " & index )
SetTextColor(index,Jfx.Colors.yellow)


Sub SetTextColor(index As Int, Color As Int   )
    StudioSpurItem.TextColor=Color
End Sub
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Are you asking for B4A or B4J?
jFX.Colors.Yellow is for B4J and is a Paint object!

In B4A, this works.
SetTextColor(index, Colors.Yellow)

Suggestion: use B4XViews, it will make your life easier.
xui colors are integers for all three platforms.
 
Upvote 0

Midimaster

Active Member
Licensed User
oh ! sorry I posted it in B4A. but I need it for B4J

xui colors are integers for all three platforms.
Ah, did'nt know that way! Now it works:

B4X:
        SetTextColor(1,xui.Color_Red)

As I transscripe my B4A-project to B4J I was happy only need to add a jfx. in front of all my color commands. But now I see it was the wrong way.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…