문제

I have a requirement of having N number of tables arranged in a grid pane side by side provided height of the scrollpanes of all the jtables remains same. Now i want to synchronize scroll of all the jtables means if i scroll the first jtable then rest of the jtables should scroll automatically by the same amount.

Anyone has any idea about this ?

도움이 되었습니까?

해결책

Try sharing the model of the scrollbar. Something like:

JScrollPane scrollPane1 = new JScrollPane(...);
JScrollPane scrollPane2 = new JScrollPane(...);
BoundedRangeModel model scrollPane1.getVerticalScrollBar().getModel();
scrollPane2.getVerticalScrollBar().setModel( model );

다른 팁

Get the scrollbars of your scrollpanes (getHorizontalScrollBar() or getVerticalScrollBar()). Then catch events from these. When an event occurs, modify the viewports (getViewport()) associated to the scrollpanes with setViewPosition() (from getViewPosition()).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top