🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #9572

Re: Getting a table to scroll a new row into view

#9572
From: E Steel
Date: Tue, 29 Feb 2000 00:00
40 lines
2168 bytes
John
    Your code snipet worked, thank you, I made one correction to the code, I
added ); at the end in case some oe else want to use this
                                Ed Steel

"John P. McGrath" wrote:

> On Mon, 28 Feb 2000 13:16:00 -0500, E Steel wrote:
>
> > I have a JTable in a JScrollPane with a vertical scrollbar with
> > autoScrolls set to true, with a subclassed DefaultTableModel that does
> > not allow editing in column 1 of the table. What I want to do is when I
> > add a row to the table I want it to scroll into view.
> >     When I do:
> >             MyTabelModel tableModel.addRow()
> >                     No scrolling takes place
> >             I added the following line of code after the addRow()
> >                 JScrollPanel.getVerticalScrollBar().setValue
> > (JScrollPanel.getVerticalScrollBar.getMaximum());
> >             The table scrolls to just before the new row, but the new
> > row does not scroll into view.
>
> The problem is that you are asking the scroll bar for its maximum value
> before the JTable has notified it that the viewport's view (the JTable)
> has grown.
>
> It may work if you delay the execution of the scrolling code until later.
> For example:
>
>     SwingUtilities.invokeLater( new Runnable() {
>         public void run() {
>             JScrollPanel.getVerticalScrollBar().setValue
>                 (JScrollPanel.getVerticalScrollBar.getMaximum());
>         }
>     });
>
> --
> John P. McGrath
> <JPMcGrath@fast.net>
> <jpm@nscs.fast.net>
Technical Details
Message-ID: <38BBDED7.91175A97@tis4000.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <38BABB60.C129836@tis4000.com> <MPG.13253752d4eaba139897cc@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,9816815c546accd2
X-Google-Attributes: gid111d45,public
From: E Steel <steel@tis4000.com>
Subject: Re: Getting a table to scroll a new row into view
Date: 2000/02/29
Message-ID: <38BBDED7.91175A97@tis4000.com>
X-Deja-AN: 591322189
Content-Transfer-Encoding: 7bit
References: <38BABB60.C129836@tis4000.com> <MPG.13253752d4eaba139897cc@forums.borland.com>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing