B4J Question Want to change button text color.

chuck3e

Active Member
Licensed User
Longtime User
I'm working with colors now. I've done several searches on color and I've found examples of changing button background colors, for example: Button01.Style = "-fx-background-color: " & colorx & ";" and changing a forms background color: MainForm.BackColor = fx.Colors.Magenta, but it's not obvious to me how to make a simple change to a button's text color within the code. I've tried several permutations of the aforementioned code but haven't found the right combination yet.
 

chuck3e

Active Member
Licensed User
Longtime User
I'm working with colors now. I've done several searches on color and I've found examples of changing button background colors, for example: Button01.Style = "-fx-background-color: " & colorx & ";" and changing a forms background color: MainForm.BackColor = fx.Colors.Magenta, but it's not obvious to me how to make a simple change to a button's text color within the code. I've tried several permutations of the aforementioned code but haven't found the right combination yet.

Yay, I found it: Buttons01.Style = "-fx-text-fill: " & "White" & ";"

I found it in here: http://docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html#typelength
which also contains all the colors and their crazy hex numbers.
 
Upvote 0

chuck3e

Active Member
Licensed User
Longtime User
Note that if the color is known then you can just write:
B4X:
Button01.Style = "-fx-text-fill: White;"

Thanks Erel, my example is the result of cut and pasting other peoples code. :) I do like yours better.
 
Upvote 0

Gaver Powers

Member
Licensed User
Longtime User
This method also works for changing the color of Labels:

B4X:
lblDayOfWeek.Style = "-fx-text-fill: Red;"
 
Upvote 0
Top