Home arrow static arrow Java Programming [Archive] - JTextArea with JScrollbar
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - JTextArea with JScrollbar
This topic has 3 replies on 1 page.

Posts:38
Registered: 4/24/04
JTextArea with JScrollbar  
Aug 9, 2004 7:52 AM



 

I populate a jtextarea with the contents of a text file. The text area has got a scrollbar. As the text has got many lines the area is set to the bottom. How can be set to the top? I mean, after populating the text area
i want to see the first line of my text file not the last one.

Many thanks,

Marla.-

 

Posts:3,369
Registered: 24.10.97
Re: JTextArea with JScrollbar  
Aug 9, 2004 7:54 AM (reply 1 of 3)



 
textArea.setCaretPosition(0); //scroll to top
 

Posts:458
Registered: 7/1/03
Re: JTextArea with JScrollbar  
Aug 9, 2004 7:55 AM (reply 2 of 3)



 
Look at the API of the scrollbar, not the text area. I dont have it right in front of me so I dont know the syntax off the top of my head. However there is a way to set the scroll position to 0.
 

Posts:458
Registered: 7/1/03
Re: JTextArea with JScrollbar  
Aug 9, 2004 7:55 AM (reply 3 of 3)



 
textArea.setCaretPosition(0); //scroll to top

LOL ... that too ... forgot about that.

 
This topic has 3 replies on 1 page.