B4J Tutorial Fix trails when moving Nodes


If youre creating apps that work with moving nodes (in my case D'n'D), you may als have seen that moving nodes sometimes results in ugly trails on the Parent Pane.

Heres how to fix that: We tell JFX to cache the nodes style, that results in a way faster redrawing.

Dim myView as Node

'when we move the Node
Dim jo as JavaObject = myView
jo.RunMethod("setCache",Array As Object(True))

'when moving is done
jo.RunMethod("setCache",Array As Object(False))

Why resetting the Cache Value to False again?

The caching is done by saving the nodes' style as Bitmap. This results in a worse performance when activated for many Nodes.

Note: You can also use "setCacheHint" to set the Caching Mode. You can find a list of the possible Modes and their description here: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/CacheHint.html