Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Scrollable TextArea

 
Dean Reedy
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a scrollable TextArea, when I add text using setText("...") the Horizantal scrollbar goes to the bottom. I want the scrollbar at the top so the use sees the text at the beginning, not the ending text.
Any ideas?
 
kate damond
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, irritating isn't it : there should be a method like .ensureIndexIsVisible(int) like there is for Lists.
But there isn't.
You can do it as a side affect of setCaretPosition :

which is a bit cheesy... but then I suppose it's logical to only let your users start editing on the bit they can see. (Seems to work for non-editable TextArea too)
Kate
 
Dean Reedy
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kate,
Thankyou!
That worked perfectly!
Dean
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic