Linking two jtextarea with one scrollbar

62 views Asked by At

I'm trying to have to jtextcompontes with one scrollbar. when I scroll I want the other jtextcomponte to scroll too.

Here's a screenshot:

https://i.stack.imgur.com/uloLn.png

1

There are 1 answers

0
camickr On

Don't try to create two separate components that scroll.

Instead, the line number component can be added as a "row header" for the scrollpane. Then the component will automatically scroll in sync.

Check out Text Component Line Number for a component you can use for the line numbers of the text area.