Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2007

Tip: Looking for answers? Try searching our database.

JTable make visible

Thread view: 
Roedy Green - 30 Dec 2007 12:58 GMT
Is there an easy way programmatically to ensure a given row in the
TableModel is visible?
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Filip Larsen - 30 Dec 2007 13:49 GMT
Roedy Green skrev:

> Is there an easy way programmatically to ensure a given row in the
> TableModel is visible?

I use JTable.getCellRect as input to JComponent.scrollRectToVisible.

Regards,
Signature

Filip Larsen

Roedy Green - 31 Dec 2007 02:45 GMT
On Sun, 30 Dec 2007 12:58:12 GMT, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :

>Is there an easy way programmatically to ensure a given row in the
>TableModel is visible?

 /**
        * make sure a given rowIndex is visible
        *
        * @param rowIndex 0-based rowIndex to make sure is scrolled
into view.
        */
       public void ensureVisible( int rowIndex )
           {
           // corral into bounds
           rowIndex = Math.max( 0, Math.min( rowIndex, allRows.size()
- 1 ) );
           final Rectangle r = jTable.getCellRect( rowIndex, 0/* col
*/, true );
           jTable.scrollRectToVisible( r );
           }

Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Roedy Green - 31 Dec 2007 12:43 GMT
On Mon, 31 Dec 2007 02:45:54 GMT, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :

>    rowIndex = Math.max( 0, Math.min( rowIndex, allRows.size()
>- 1 ) );

It turns out this is unnecessary.  It can handle out of bounds rows on
its own.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.