• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to scroll to top of JScrollPane  RSS feed

 
Mike London
Ranch Hand
Posts: 1340
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JTextArea inside a JScrollPane.
Now, after I add a whole bunch of stuff to the JTextArea, I'd like to, programmatically, "scroll" (go back and display) to the top of the JTextArea so the user sees the top part, not the bottom part.
I can't seem to get this to work though I've tried various methods and defining rectangles and such.
Is programmatically going back to the top of a JTextArea within a JScrollPane (after populating the JTextArea) easily done?
Any ideas would be welcome!
Thanks.
-- Mike
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
VIJAY Yadlapati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can comfortably use
scrollrectToVisible(new Reatangle(0,0,someWidth, someHeight)) method, as it's defined in JComponent.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!