B4J Question Text shadow

micro

Well-Known Member
Licensed User
Longtime User
Hi to all
I have put in extra CSS properties of a Textfield (Internal Designer) this line:
B4X:
-fx-text-shadow: 2px 2px #ff0000;
but not work.
Where wrong?
Thanks
 

micro

Well-Known Member
Licensed User
Longtime User
I'm implementing the function with javaobject but there are same problems
B4X:
Private shadow as JavaObject
shadow.InitializeStatic("javafx.scene.effect.DropShadow")
shadow.RunMethod("setRadius", Array As Object("5"))
shadow.RunMethod("setOffsetX", Array As Object("3"))
shadow.RunMethod("setOffsetY", Array As Object("3"))
shadow.RunMethod("setColor", Array As Object("0, 0, 0"))
........
java.lang.RuntimeException: Method: setRadius not matched.
and also SetOffsetX ecc.
where I'm wrong?
Thanks
 
Upvote 0

micro

Well-Known Member
Licensed User
Longtime User
DropShadow will not add the shadow to the text. It will add it to the whole field.
Ther's an article on oracle doc:
B4X:
https://docs.oracle.com/javafx/2/text/jfxpub-text.htm

Drop Shadow Effect
To implement a drop shadow effect, use the DropShadow class. You can specify a color and an offset for the shadow of your text. In the TextEffects application, the drop shadow effect is applied to the red text and provides a three-pixel gray shadow. You can see the code in Example 15.

Example 15

DropShadow ds = new DropShadow();
ds.setOffsetY(3.0f);
ds.setColor(Color.color(0.4f, 0.4f, 0.4f));

Text t = new Text();
t.setEffect(ds);
t.setCache(true);
t.setX(10.0f);
t.setY(270.0f);
t.setFill(Color.RED);
t.setText("JavaFX drop shadow...");
t.setFont(Font.font(null, FontWeight.BOLD, 32));

 
Upvote 0

micro

Well-Known Member
Licensed User
Longtime User
You are correct. It will show the text shadow for a Label
Ok, now where i wrong?
About the JavaObject code as you suggested:
B4X:
shadow.InitializeStatic("javafx.scene.effect.DropShadow")
Dim offsetX = 3, offsetY = 3, radius = 5 As Double
shadow.RunMethod("setRadius", Array(radius))
shadow.RunMethod("setOffsetX", Array As Object(offsetX))
shadow.RunMethod("setOffsetY", Array As Object(offsetY))
Line 19 java.lang.IllegalArgumentException: object is not an instance of declaring class...(shadow.RunMethod("setRadius", Array(radius)))
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…