(generally) in a while() you change the position of the ball, add a Thread.sleep(..) and call repaint(). This gives you the effect of animation.
Your problem is you appear to be doing this in the EDT (event thread) which also handles painting, so, any painting is blocked until the while() terminates, then you get your 'last frame' showing.
solution is to move your while() into a separate thread
I just found out that when I comment-out the repaint(), the file can be updated properly within each loop. So the problem should be around the transfer of data from file into panel, not the JNI.
you would need to post the code - preferably a working example.
(actually, that would be a working 'non-working' example!)
to run your code we would need a sample of what's in DataArrayTest.txt
0 times.
1 times.
2 times.
File rewrited...
Array plotted...
3 times.
File rewrited...
4 times.
File rewrited...
5 times.
6 times.
File rewrited...
Array plotted...
7 times.
File rewrited...
8 times.
File rewrited...
9 times.
File rewrited...
10 times.
File rewrited...
Array plotted...
11 times.
paintComponent() is called may times, for many reasons.
Each time it would be reading the file. This does not seem to be what you want.
I'm just a poor boy, I need no sympathy, because I'm easy come, easy go, little high, little low, little ad
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|