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 / February 2005

Tip: Looking for answers? Try searching our database.

how to make of a specific row the first row  (toprow) in the visible area

Thread view: 
Anand Misier - 17 Feb 2005 17:42 GMT
Hi,

Can anyone tell me how i can show a specific row as the first one in
the visible area of a JTable.

For example:
I have 100 rows in a JTable but only 10 are shown in the visible area.
At a certain moment i want to make forexample row 23 as the first one
in the visible area of a JTable in a scrollpanel.

Bye
Roland - 17 Feb 2005 18:39 GMT
> Hi,
>
[quoted text clipped - 7 lines]
>
> Bye
This is what I wrote once:

void showRow(int rowIndex)
{
  if (rowIndex >= 0 && rowIndex < myTable.getModel().getRowCount())
  {
    Rectangle vr = myTable.getVisibleRect();
    Rectangle cr = myTable.getCellRect(rowIndex, 0, false);
    vr.y = cr.y;
    vr.height = cr.height;
    myTable.scrollRectToVisible(vr);
  }
}

Signature

Regards,

Roland de Ruiter
  ___      ___
 /__/ w_/ /__/
/  \ /_/ /  \

Anand Misier - 19 Feb 2005 21:32 GMT
Thanks Roland,

It works perfect!

Bye,

Anand

>> Hi,
>>
[quoted text clipped - 20 lines]
>   }
>}


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



©2010 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.