nobbi59 Active Member Licensed User Longtime User Nov 30, 2017 #1 Hello all, Im having an issue with a ScrollPane. I add the ScrollPane by code and also add its content by code. The content becomes blurry, a big problem especially with text. So I googled a bit and found the solution for this. First I tried it with Integer-only positioning values but this didnt work. Then I found a Java Code for fixing this: Code: import com.sun.javafx.scene.control.skin.ScrollPaneSkin; import java.lang.reflect.Field; import javafx.scene.Node; import javafx.scene.control.ScrollPane; import javafx.scene.layout.StackPane; public class FieldUtils { public static void fixBlurryText(Node node) { try { Field field = ScrollPaneSkin.class.getDeclaredField("viewRect"); field.setAccessible(true); ScrollPane scrollPane = (ScrollPane) node.lookup(".scroll-pane"); StackPane stackPane = (StackPane) field.get(scrollPane.getSkin()); stackPane.setCache(false); } catch (NoSuchFieldException | SecurityException | IllegalAccessException e) { e.printStackTrace(); } } } The forum user that posted this code commented this code with: I checked the internal skin code and found a workaround, not pretty though. The problem is inside com.sun.javafx.scene.control.skin.ScrollPaneSkin, which calls viewRect.setCache(true). Disabling cache appears to solve the problem. Click to expand... I dont know anything about Java. Can somebody help me that I can use this code inside B4J?
Hello all, Im having an issue with a ScrollPane. I add the ScrollPane by code and also add its content by code. The content becomes blurry, a big problem especially with text. So I googled a bit and found the solution for this. First I tried it with Integer-only positioning values but this didnt work. Then I found a Java Code for fixing this: Code: import com.sun.javafx.scene.control.skin.ScrollPaneSkin; import java.lang.reflect.Field; import javafx.scene.Node; import javafx.scene.control.ScrollPane; import javafx.scene.layout.StackPane; public class FieldUtils { public static void fixBlurryText(Node node) { try { Field field = ScrollPaneSkin.class.getDeclaredField("viewRect"); field.setAccessible(true); ScrollPane scrollPane = (ScrollPane) node.lookup(".scroll-pane"); StackPane stackPane = (StackPane) field.get(scrollPane.getSkin()); stackPane.setCache(false); } catch (NoSuchFieldException | SecurityException | IllegalAccessException e) { e.printStackTrace(); } } } The forum user that posted this code commented this code with: I checked the internal skin code and found a workaround, not pretty though. The problem is inside com.sun.javafx.scene.control.skin.ScrollPaneSkin, which calls viewRect.setCache(true). Disabling cache appears to solve the problem. Click to expand... I dont know anything about Java. Can somebody help me that I can use this code inside B4J?
Daestrum Expert Licensed User Longtime User Nov 30, 2017 #2 Not tried it but the following code 'may' do the same Requires JavaObject Library Code: ... Dim jo As JavaObject = yourscrollpane jo.RunMethod("setCache",array(False)) ... Upvote 0
Not tried it but the following code 'may' do the same Requires JavaObject Library Code: ... Dim jo As JavaObject = yourscrollpane jo.RunMethod("setCache",array(False)) ...
Erel B4X founder Staff member Licensed User Longtime User Dec 1, 2017 #3 nobbi59 said: I add the ScrollPane by code and also add its content by code. Click to expand... This is a mistake in most cases. Does the text get blurred in this example: https://www.b4x.com/android/forum/t...listview-cross-platform-customlistview.84501/ ? The code above requires jReflection as it accesses private fields. Code: Dim jo As JavaObject = yourscrollpane Dim r As Reflector r.Target = jo.RunMethod("getSkin", Null) jo = r.GetField("viewRect") jo.RunMethod("setCache", Arrary(False)) Upvote 0
nobbi59 said: I add the ScrollPane by code and also add its content by code. Click to expand... This is a mistake in most cases. Does the text get blurred in this example: https://www.b4x.com/android/forum/t...listview-cross-platform-customlistview.84501/ ? The code above requires jReflection as it accesses private fields. Code: Dim jo As JavaObject = yourscrollpane Dim r As Reflector r.Target = jo.RunMethod("getSkin", Null) jo = r.GetField("viewRect") jo.RunMethod("setCache", Arrary(False))
nobbi59 Active Member Licensed User Longtime User Dec 2, 2017 #4 Thanks @Daestrum, tried it but it didnt work. @Erel it doesnt become blurry in your example. I tried your code but this doesnt help. The solution provided doesnt seem to be the one that fixes it in my case. Do you have any other suggestions? Upvote 0
Thanks @Daestrum, tried it but it didnt work. @Erel it doesnt become blurry in your example. I tried your code but this doesnt help. The solution provided doesnt seem to be the one that fixes it in my case. Do you have any other suggestions?
Erel B4X founder Staff member Licensed User Longtime User Dec 3, 2017 #5 nobbi59 said: it doesnt become blurry in your example. Click to expand... You need to find out why it works properly in CustomListView and not in your code. CustomListView is made of SrollPane with panes. Upvote 0
nobbi59 said: it doesnt become blurry in your example. Click to expand... You need to find out why it works properly in CustomListView and not in your code. CustomListView is made of SrollPane with panes.
nobbi59 Active Member Licensed User Longtime User Dec 4, 2017 #6 That seems very crazy. My fisrt guess was the positioning with non-integer values, I tried to round the values but this doesnt seem to fix it. Upvote 0
That seems very crazy. My fisrt guess was the positioning with non-integer values, I tried to round the values but this doesnt seem to fix it.