
Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
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
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