• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Positioning the scroll bar..

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello..
I'm having a lil problem, as follows:
I have a JTextArea within a JScrollPane. I keep refreshing the JTextArea with new text, so each time after I refresh the textarea, the scrollbar is positioned at the bottom of the textarea. Is there a way to automatically position it at the top after each refresh?
Also, can two or more components be placed within the same JScrollPane?
Thanks!
 
Tris Rabar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need some urgent help!!
Thanks!
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JViewport class has a method called scrollRectToVisible() that you can call when you update your text area. JScrollPane has a method called getViewport() that will let you get a reference to the viewport of your JScrollPane.

Only one component per scroll pane... but that one component can be a JPanel that contains two (or more...) components.

-Nate
 
reply
    Bookmark Topic Watch Topic
  • New Topic