Article View: borland.public.jbuilder.java.swing
Article #12315Any way to keep two JScrollPanes in sync???
From: Kyle
Date: Tue, 19 Jan 1999 00:00
Date: Tue, 19 Jan 1999 00:00
41 lines
1847 bytes
1847 bytes
I'm using the example in chapter 16 of the book Java Swing by Robert
Eckstein that shows how to share two JTables with a common TableModel so
that the selections and such are reflected in the two different views.
What is does not show is how to scroll in one JScrollPane and have the
other JScrollPane scroll along with it.
Any ideas how to do this?
Here is a snippit of what works so far...
JScrollPane jScrollPane1 = new JScrollPane();
JTable jTable1 = new JTable(myTableModel, HeaderModel1);
JScrollPane jScrollPane2 = new JScrollPane();
JTable jTable2 = new JTable(myTableModel, HeaderModel2);
JScrollPane jScrollPane3 = new JScrollPane();
JTable jTable3 = new JTable(myTableModel, HeaderModel3);
jScrollPane1.setColumnHeaderView(jTable1.getTableHeader());
jScrollPane2.setColumnHeaderView(jTable2.getTableHeader());
jScrollPane3.setColumnHeaderView(jTable3.getTableHeader());
jTable2.setSelectionModel(jTable1.getSelectionModel());
jTable3.setSelectionModel(jTable1.getSelectionModel());
Any ideas how to keep the scrolling in sync?
Thanks in advance...
Kyle
P.S. I tried this and it did not work:
jScrollPane2.getLayout().
addLayoutComponent(ScrollPaneConstants.VERTICAL_SCROLLBAR,
jScrollPane1.getVerticalScrollBar());
jScrollPane3.getLayout().addLayoutComponent(ScrollPaneConstants.VERTICAL_
SCROLLBAR, jScrollPane1.getVerticalScrollBar());
Technical Details
Message-ID:
<MPG.110ee1a1f1a8183d989692@forums.inprise.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,e33957ec48c6841,start X-Google-Attributes: gid111d45,public From: A@a.com (Kyle) Subject: Any way to keep two JScrollPanes in sync??? Date: 1999/01/19 Message-ID: <MPG.110ee1a1f1a8183d989692@forums.inprise.com> X-Deja-AN: 434619180 Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.swing