wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes Scrollable TextArea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Scrollable TextArea " Watch "Scrollable TextArea " New topic
Author

Scrollable TextArea

Dean Reedy
Ranch Hand

Joined: Sep 10, 2001
Posts: 89
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

Joined: Apr 17, 2001
Posts: 77
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

Joined: Sep 10, 2001
Posts: 89
Kate,
Thankyou!
That worked perfectly!
Dean
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Scrollable TextArea
 
Similar Threads
Dynamically setting TextArea size
TextArea scrollbar problem
JTextArea
Scrolling with mouse wheel in scrollpane without scrollbar
Adding horizontal scroll bars to list box