ARACK04
asked on
keep JScrollPane at bottom
As I add text to a JTextPane which is in a JScrollPane, how can I keep the JScrollPane at the bottom, in other words, make it so I don't need to scroll down every time I add text to it.
I'm guessing I would want to keep updating the viewPosition, but I'm not sure how to do that. Maybe get the bottom corner of the accessibleContext into a Point somehow???
I'm guessing I would want to keep updating the viewPosition, but I'm not sure how to do that. Maybe get the bottom corner of the accessibleContext into a Point somehow???
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
textArea.setCaretPosition( textArea.getText().length( ) );
Or you can try calling the setValue () method of the veritical scroll-bar.
ASKER
Thanks, just so you don't think I'm terribly stupid, I was looking in the JScollPane documentation...which is why I missed that method...of course if I really was *not stupid* I suppose I would have looking in JTextPane. Anyway, thanks
I don't think you're stupid :)
>> I was looking in the JScollPane documentation
You would find getverticalScrollbar () in it ;-) and then setValue () in JScrollbar.
You would find getverticalScrollbar () in it ;-) and then setValue () in JScrollbar.