• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

How to scroll to top of JScrollPane  RSS feed

 
Ranch Hand
Posts: 1574
13
  • 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
 
Bartender
Posts: 9511
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
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!