[Advanced-java] How to scroll JTable in code?

Alvin Wang xwang at qtechservices.com
Wed Mar 5 19:06:33 2003


Thanks for all the helps! Finally I figured out the solution:
        
Rectangle rect = table.getCellRect(row, 0, true);
scrollPane.getViewport().setViewPosition(rect.getLocation());


> -----Original Message-----
> From: advanced-java-bounces@lists.xcf.berkeley.edu
> [mailto:advanced-java-bounces@lists.xcf.berkeley.edu]On Behalf Of Alvin
> Wang
> Sent: Tuesday, March 04, 2003 3:48 PM
> To: Lorin Davis; advanced-java@lists.xcf.berkeley.edu
> Subject: RE: [Advanced-java] How to scroll JTable in code?
> 
> 
> Thanks! However, your way can only scroll the row to the bottom 
> of the pane,
> not the top of the pane... Any improvements?
> 
> 
> 
> > -----Original Message-----
> > From: advanced-java-bounces@lists.xcf.berkeley.edu
> > [mailto:advanced-java-bounces@lists.xcf.berkeley.edu]On Behalf Of Lorin
> > Davis
> > Sent: Tuesday, March 04, 2003 3:21 PM
> > To: 'Alvin Wang'; advanced-java@lists.xcf.berkeley.edu
> > Subject: RE: [Advanced-java] How to scroll JTable in code?
> >
> >
> > If  you know the row number you want to goto in the JTable why not just
> > Change the selection selection on the JTable to that row
> >
> > ie) JTable.changeSelection (rowIndex, colIndex, false, false);
> >
> > -----Original Message-----
> > From: Alvin Wang [mailto:xwang@qtechservices.com]
> > Sent: Tuesday, March 04, 2003 12:19 PM
> > To: advanced-java@lists.xcf.berkeley.edu
> > Subject: [Advanced-java] How to scroll JTable in code?
> >
> >
> > Hi, in my code, I want to scroll a JTable (in a JScrollPane) to 
> a specific
> > row. Can anyone tell me how to do this? thanks!
> >
> > Alvin
> >
> > _______________________________________________
> > Advanced-java mailing list
> > Advanced-java@lists.xcf.berkeley.edu
> > http://lists.xcf.berkeley.edu/mailman/listinfo/advanced-java
> > _______________________________________________
> > Advanced-java mailing list
> > Advanced-java@lists.xcf.berkeley.edu
> > http://lists.xcf.berkeley.edu/mailman/listinfo/advanced-java
> 
> _______________________________________________
> Advanced-java mailing list
> Advanced-java@lists.xcf.berkeley.edu
> http://lists.xcf.berkeley.edu/mailman/listinfo/advanced-java