After some more testing with our real application, there are still some funny things remaining:
1) Often the first time I call "getCharacterBounds" after an arbitrary insert it gets really large Y values:
index: 90, char 0xa, bounds: org.apache.pivot.wtk.Bounds [4,1306;2x16]
index: 123, char 0x2e, bounds: org.apache.pivot.wtk.Bounds [214,116;7x16]
2) It seems to not scroll enough so that by the last line often the last one or more lines are not visible. This looks to be because the TextArea component height isn't getting updated correctly. For instance, in this case the Bounds is returning a Y value of 308 (plus line size of 16), but the viewHeight for the TextArea component (during "scrollAreaToVisible") is only returning 280, resulting in an incorrect "scrollTop" calculation:
index: 414, char 0xa, bounds: org.apache.pivot.wtk.Bounds [291,308;2x16]
scrollAreaToVisible: area [291,304,2,16], viewport org.apache.pivot.wtk.Bounds [0,0;523x260]
scrollAreaToVisible: deltaX = 0
scrollAreaToVisible: deltaY = 60
scrollAreaToVisible: viewHeight = 280
scrollAreaToVisible: new scrollTop=20
But, if you take the scrollbar to the bottom end, the final "scrollTop" gets to be (and should be) 84 (which includes the 308 + 16 for that line, plus another 16 for the empty line at the bottom + 4 for ??, or 344 altogether which = 260 + 84). So, the cumulative error is 64 pixels in this example, which leaves me about 4 lines still scrolled off the bottom.
As you can probably tell, I still don't understand all the calculations involved here.
You can see these errors (a little bit, not as pronounced) using the example code.
I put tracing statements into Component.scrollAreaToVisible to get these results.
Thanks again for your attention to this issue.