• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 324
  • Last Modified:

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???
0
ARACK04
Asked:
ARACK04
  • 3
  • 2
1 Solution
 
objectsCommented:
Call setCaretPosition() after adding text
0
 
objectsCommented:
textArea.setCaretPosition( textArea.getText().length() );
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Or you can try calling the setValue () method of the veritical scroll-bar.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ARACK04Author Commented:
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
0
 
objectsCommented:
I don't think you're stupid :)
0
 
Mayank SAssociate Director - Product EngineeringCommented:
>> I was looking in the JScollPane documentation

You would find getverticalScrollbar () in it ;-) and then setValue () in JScrollbar.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now