Automatic scroll down to bottom of TextArea (or other component)


I’m creating a screen with an large outputArea where the log results of a separate batch job are shown (kind of a tail functionality where the last lines are shown, however all previous lines should be also accessible by scrolling up.
So the batch job logs all kinds of information and the screen will show every new line in the outputArea.

I used to have a ListSelect component where I could easily do a<>) which forced the component to automatically scroll down to the last line.
However the drawback here was that a user was not able to select one line and do a copy/paste to paste the information in an TextEditor for example.

So I swichted to a TextArea component but now the automatic scroll down to the last line does not work anymore.

Does anyone have any ideas on which component to use (which one is most suitable) and how to use it ?
As stated these are the requirements:

  • automatic scroll down to the last line
  • copy/paste support
  • scrollbars because some lines are to long to show in the outputArea

Thank you for your help.

Kind regards,
Richard Aalten
TNT Express ICS

Hi Richard,

I do it this way:

    if (cb.getLogEntries() != null)
      memo.setCursorPosition(cb.getLogEntries().length() - 1);

Copy/paste works out of the box. Scrollbars show up automatically in my app. Unfortunately, some browser don’t scroll to the end, but FF and Opera do scroll down. I did already filed a
. If you have a pro account you can mark this ticket as priority.



Hi Andreas,

Thank you for your reply.

The ListSelect did something similar only I did not knew the setCursorPosition method.

It works fine now.

Thanx again.


I use a different solution. I add a Label component to represent a line inside a Panel. To scroll down, I use panel.setScrollTop(Integer.MAX_VALUE).

The following code:
txtArea.setCursorPosition(65535 /big value/);

Seems not being fixed for Chrome yet. It does work under Firefox.

Any other idea to make it work when in Chrome?

I’m not sure if this is an issue/limitation in Chrome rather than in Vaadin, but you can
create a ticket
about this.

I was struggling with the same issue using Safari & Chrome.

Finally, this solution seemed acceptable to me :

txtArea.setSelectionRange(txtArea.getValue().length()-1, 1);

any suggestions for a better approach working in most common browsers ?

not really, but setting 0 as last param makes at least the selection disappear:

txtArea.setSelectionRange(chatbox.getValue().length() - 1, 0);

Hello all,

That seems to works well.


Bertrand Pivaty:
Hello all,

That seems to works well.


I can confirm this method works fine for a ‘tail’ function.