Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Jim Gibson Newsgroups: comp.lang.java.programmer Subject: Re: How To Determine Position of JScrollPane in One JTable and Scroll Second JTable Date: Mon, 03 Jun 2013 16:56:52 -0700 Lines: 19 Message-ID: <030620131656529935%jimsgibson@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: individual.net UEaZI1NQ9TT8XU7vqtxDhwW2VA0uxtBTsvwOnMOgC6Jlmo2KHS X-Orig-Path: jimsgibson Cancel-Lock: sha1:E/z82izFgeRWLPViE46aIMvodK0= User-Agent: Thoth/1.9.0 (Mac OS X) Xref: csiph.com comp.lang.java.programmer:24279 In article , Haircuts Are Important wrote: > How can I determine how much a JTable's JScrollPane has been moved, > and then scroll a second JTable based on that movement. JScrollPane has two JScrollBar members: horizontalScrollBar and verticalScrollBar. Use the getVerticalScrollBar() method of JScrollPane, for example, to get the vertical scroll bar object. Then use the getValue() method of JScrollBar to find out where the scrollbar is positioned. You can define an AdjustmentListener object to listen for scroll bar events. Then use the setValue() method to apply the same offset to the other JScrollPane (assuming everything else about the two JScrollPanes is equal). -- Jim Gibson