Bug? TreeView with images

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm unable to reproduce it with TreeView. Tested with this code:
B4X:
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
   Private TreeView1 As TreeView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.RootPane.LoadLayout("1") 'Load the layout file.
   MainForm.Show
   Dim flags() As String = Array As String("france", "germany", "japan")
   For i = 1 To 100
     Dim ti As TreeItem
     ti.Initialize("", "Item " & i)
     ti.Image = fx.LoadImage(File.DirAssets, flags(Rnd(0, flags.Length)) & ".png")
     For ii = 1 To 5
       Dim c As TreeItem
       c.Initialize("", "child")
       ti.Children.Add(c)
       c.Image = fx.LoadImage(File.DirAssets, flags(Rnd(0, flags.Length)) & ".png")
     Next
     TreeView1.Root.Children.Add(ti)
   Next
End Sub
 

Informatix

Expert
Licensed User
Longtime User
I'm unable to reproduce it with TreeView. Tested with this code:
B4X:
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
   Private TreeView1 As TreeView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.RootPane.LoadLayout("1") 'Load the layout file.
   MainForm.Show
   Dim flags() As String = Array As String("france", "germany", "japan")
   For i = 1 To 100
     Dim ti As TreeItem
     ti.Initialize("", "Item " & i)
     ti.Image = fx.LoadImage(File.DirAssets, flags(Rnd(0, flags.Length)) & ".png")
     For ii = 1 To 5
       Dim c As TreeItem
       c.Initialize("", "child")
       ti.Children.Add(c)
       c.Image = fx.LoadImage(File.DirAssets, flags(Rnd(0, flags.Length)) & ".png")
     Next
     TreeView1.Root.Children.Add(ti)
   Next
End Sub
I reproduce it easily with your code. I forgot to mention that you have to scroll with the keyboard arrows. With the mouse, that works flawlessly.
 

ilan

Expert
Licensed User
Longtime User
hi, i have just tried your example @Informatix (Flags example - jTreeViewExtended) and it works fine.
i scroll down/up with keyboard or mouse and nothing disappear.

i am using windows 10, java 1.8.0_91
 

Informatix

Expert
Licensed User
Longtime User
hi, i have just tried your example @Informatix (Flags example - jTreeViewExtended) and it works fine.
i scroll down/up with keyboard or mouse and nothing disappear.

i am using windows 10, java 1.8.0_91
I'm unable to replicate the problem under Windows 7 on a different PC with the same Java version, so the problem seems to be restricted to Windows 10 64 bits (updated with the latest patches this week-end). I can see what happens by tracking the calls to updateItem in Java under Windows 10: when there's a graphic, the item is updated twice and the graphic, which is null in the first call, is not refreshed when set afterwards. I don't know why that's limited to Windows 10. I will try to find a workaround.
 

Informatix

Expert
Licensed User
Longtime User
After a few tests, I confirm that this problem appears only with Windows 10 (at least the 64 bits version; I cannot test the 32 bits version as I don't have it). The same program run with the same JRE on the same PC with different OS shows a different behavior under W10 when you scroll with the keyboard. It's a real issue for my main project as graphics are not decorative.
 

Informatix

Expert
Licensed User
Longtime User
i am using windows 10 64 bit and i have no issues
I have the same problem on two PC so I think that the problem can happen anywhere. Here's how you can reproduce the issue step by step:
- in the list, expand all countries
- use the down key and go to the bottom of the list
- then go up with the arrow key
Some flags should be invisible.
Moreover I found on Internet a user reporting a problem of disappearing graphics with TreeView (not exactly the same) but the given solution seems to work also in my case.
 

ilan

Expert
Licensed User
Longtime User
yes i understand that it can be in other pc's too but on my i cannot reproduce such an issue. but i need to mention that i dont have the latest Java version.
have a look at the video:

'....

if you need me to do any tests let me know :)
 
Last edited:

Informatix

Expert
Licensed User
Longtime User
yes i understand that it can be in other pc's too but on my i cannot reproduce such an issue. but i need to mention that i dont have the latest Java version.
have a look at the video:


if you need me to do any tests let me know :)
I have no idea why that works on your PC and not on mine. My two PC at home have only the OS in common. Their hardware and installed softwares are completely different. As my main project is run only on my PC, it is of course important to me to fix this issue, but I prefer to warn others that may happen anywhere as my case is not limited to a single computer. And, as said, I found another report of visual glitches with TreeView. There's something wrong in the JavaFX code that causes these issues only under certain circumstances, but I don't know which ones. Fortunately, there's a workaround.
 

ilan

Expert
Licensed User
Longtime User
Fortunately, there's a workaround

ok, if there is a workaround then it make sense to use it to ensure your lib will work on every pc.
just to let you know i have also tested the jar file on my Mac and it doesnot run.

normally b4j jar's should run on Mac but the jar doesnot start at all.

ohh and btw i am using B4J v4.50. i am not sure that it is related to b4j but when i opened the project i was warned that the project was created on a newer version.
 

Informatix

Expert
Licensed User
Longtime User
ok, if there is a workaround then it make sense to use it to ensure your lib will work on every pc.
just to let you know i have also tested the jar file on my Mac and it doesnot run.

normally b4j jar's should run on Mac but the jar doesnot start at all.

ohh and btw i am using B4J v4.50. i am not sure that it is related to b4j but when i opened the project i was warned that the project was created on a newer version.
What's the Java version on your Mac?

I made some progress in the understanding of the problem thanks to Scenic View (in the cells where the image is not visible, the reason is clear: the imageview is not added to the cell node. Why? I don't know. My workaround adds the ImageView when it is missing and that works fine.)
 
Top