Aha, nevsiml jsem si, ze je definovana az na JXTable, kterou pouzivam a ta
to dela takhle:
/**
* Scrolls vertically to make the given row visible. This might not have
any
* effect if the table isn't contained in a <code>JViewport</code>.
* <p>
*
* Note: this method has no precondition as it internally uses
* <code>getCellRect</code> which is lenient to off-range coordinates.
*
* @param row the view row index of the cell
*
* @see #scrollColumnToVisible(int)
* @see #scrollCellToVisible(int, int)
* @see #scrollRectToVisible(Rectangle)
*/
public void scrollRowToVisible(int row) {
Rectangle cellRect = getCellRect(row, 0, false);
Rectangle visibleRect = getVisibleRect();
cellRect.x = visibleRect.x;
cellRect.width = visibleRect.width;
scrollRectToVisible(cellRect);
}
-Vity
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Arne
> Sent: Wednesday, December 03, 2008 2:26 PM
> To: Java
> Subject: RE: scrolling v s JTable
>
> Tohle asi nebude to pravé.
>
> Nenašel jsem u třídy JTable žádnou medodu
> scrollRowToVisible((up) ? rows[0] : rows[length - 1]);
>
> Takže jsem googlil a podařilo se mi najít příklad v konferenci
>
> http://forums.sun.com/thread.jspa?threadID=561327
>
> takže správné řešení, kreré mi funguje je:
>
> int row =tableListManager.findRowOfValues( c1,c2 );
> if (row > 0 )
> {
> tableSlovicka.setRowSelectionInterval(row,row);
> Rectangle bounds = tableSlovicka.getCellRect(row,0,true);
>
> scrollPaneSlovicka.getViewport().setViewPosition(bounds.getLoc
> ation());
> }
> else
>
> JOptionPane.showMessageDialog(getContentPane(),"Nenalezeno.");
>
> Ale i tak díky za pomoc !
> Arne
>
> > ------------ Původní zpráva ------------
> > Od: Vity <[EMAIL PROTECTED]>
> > Předmět: RE: scrolling v s JTable
> > Datum: 03.12.2008 11:51:19
> > ----------------------------------------
> > Zdravim,
> > pouzivam tuto funkci :
> > - up urcuje, zda se ma posunout vuci poslednimu nebo
> prvnimu radku v
> > selekci
> > private void scrollToVisible(final boolean up) {
> > final int[] rows = table.getSelectedRows();
> > final int length = rows.length;
> > if (length > 0)
> > table.scrollRowToVisible((up) ? rows[0] :
> rows[length - 1]);
> > }
> >
> > Staci ji volat dle libosti - napr. navesit si udalost na
> SelectionModel
> > tabulky...
> >
> > -Vity