Re: JScrollPane + auto-scroll to the last appended line



oleth wrote:
Hello
I have an un-editable JScrollPane (a simple JtextArea). I append lines
to it when some events in my program happen.

I would like to ask how to make the scrollpane to scroll always down to
the last appened line. Currently the scroll pane's viewport stays in
the original place. When the pane is full, more lines are added, the
scroll bar appears, but it doesn't automatically scroll to the last
appended line. I have to scroll it manually to see the newest line
appended. How can I avoid it?

I 've searched the documentation but I had problems finding the correct
terminology to find this out.

Thanks

Something like this...

textArea.setCaretPosition(textArea.getText().length());

--

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
.



Relevant Pages

  • Re: ScrollPane - automatic scrolling
    ... in the begining of JTextArea). ... I believe this (failure to scroll to the bottom) happens when the text ... is appended from a thread that isn't the Event Dispatch Thread. ... Wrapping the append call in SwingUtilities.invokeLater wrapper should ...
    (comp.lang.java.programmer)
  • JScrollPane + auto-scroll to the last appended line
    ... I have an un-editable JScrollPane (a simple JtextArea). ... I append lines ... I would like to ask how to make the scrollpane to scroll always down to ...
    (comp.lang.java.help)
  • Re: Textbox scrolling
    ... It sounds like you want to scroll somewhere in the ... I suggest you look at the examples from the second link and work it ... > These only show how to scroll to the bottom, ... I need to append text with no scrolling at all. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Textbox scrolling
    ... The second link shows an alternative way to control scrolling by pinvoking. ... It sounds like you want to scroll somewhere in the middle. ... The ideal solution is to be able to append text with no scrolling at all. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: How to Scroll Bottom of RichTextbox into View
    ... > I have a RichTextbox to which I append text. ... It is not very tall, ... > a scroll bar quite quickly. ...
    (microsoft.public.dotnet.languages.vb)