aspose file tools
The moose likes Swing / AWT / SWT / JFace and the fly likes Scrollable TextArea Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply 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
 
 
subject: Scrollable TextArea
 
Threads others viewed
TextArea scrollbar problem
JTextArea
Scrolling with mouse wheel in scrollpane without scrollbar
Dynamically setting TextArea size
Adding horizontal scroll bars to list box
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com