Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #197

Re: JScrollPane - ScrollB

From "Nigel Wade" <nigel.wade@THRWHITE.remove-dii-this>
Subject Re: JScrollPane - ScrollB
Message-ID <ekee37$oba$1@south.jnrs.ja.net> (permalink)
Newsgroups comp.lang.java.gui
References <jan9h.462$ZM.34@newsfe11.lga>
Date 2011-04-27 15:26 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
Bill wrote:

> Hi All,
> 
>     I have a JScrollPane containing a JTable.
> 
>     I programatically traverse the JTable by selecting rows and  scrolling 
> the JTable
> 
>             jTable.scrollRectToVisible(r);
> 
> 
>     However the scrollbar doesn't get updated until after all my processing 
> has completed, then the scrollbar 'jumps' to the bottom. Is there any way to 
> get it to be updated while the jTable is being processed, so the user has 
> some indication of how far the processing has progressed?
> 
> TIA
> 
> Bill

Without seeing your code I can only guess, but you've probably hijacked the EDT
to do your processing. Whilst the EDT is processing your code it can't get on
with what it's supposed to be doing, updating the GUI.

Whatever processing you are doing which calls jTable.scrollRectToVisible(r);
must be done in a thread other than the EDT if you want to see the effects of
that method. Also, note that JComponent.scrollRectToVisible() doesn't say it's
thread safe, so if you want to use it from another thread then you really ought
to wrap that call in a SwingUtilities.invokeLater().

I was going to recommend the section in the Java Tutorial "Creating a GUI with
JFC/Swing", but Sun seem to have re-written this for Java 1.6. The tutorial now
only mentions the use of SwingWorker for creating multiple threads in Swing
(SwingWorker isn't even part of Java 1.5, it's a separate download). 
 
-- 
Nigel Wade, System Administrator, Space Plasma Physics Group,
            University of Leicester, Leicester, LE1 7RH, UK 
E-mail :    nmw@ion.le.ac.uk 
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Find similar


Thread

JScrollPane - ScrollBar - "Bill" <bill@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
  Re: JScrollPane - ScrollB "Bart Cremers" <bart.cremers@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
    Re: JScrollPane - ScrollB "Ian Wilson" <ian.wilson@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
    Re: JScrollPane - ScrollB "Bill" <bill@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
  Re: JScrollPane - ScrollB "Nigel Wade" <nigel.wade@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000

csiph-web