-2

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

camickr
  • 321,443
  • 19
  • 166
  • 288
SSM
  • 379
  • 5
  • 16
  • You'd better of making use of the `JScrollPane`'s `rowHeader` support, [for example](http://stackoverflow.com/questions/34010090/moving-the-visible-area-of-a-jscrollpane-to-a-specific-position/34011257#34011257), [example](http://stackoverflow.com/questions/36391104/how-to-create-this-grid-like-layout-with-column-and-row-labels/36392158#36392158), [example](http://stackoverflow.com/questions/21766588/make-jscrollpane-control-multiple-components/21767752#21767752) – MadProgrammer Apr 09 '17 at 05:38

1 Answers1

2

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.

camickr
  • 321,443
  • 19
  • 166
  • 288