Here you can find the source of scrollToSelectedRow(JTable table)
private static void scrollToSelectedRow(JTable table)
//package com.java2s; //License from project: Apache License import javax.swing.*; import java.awt.*; public class Main { private static void scrollToSelectedRow(JTable table) { JViewport viewport = (JViewport) table.getParent(); Rectangle cellRectangle = table.getCellRect(table.getSelectedRow(), 0, true); Rectangle visibleRectangle = viewport.getVisibleRect(); SwingUtilities.invokeLater(() -> table.scrollRectToVisible(new Rectangle(cellRectangle.x, cellRectangle.y, (int) visibleRectangle.getWidth(), (int) visibleRectangle.getHeight()))); } }/*from www .j a v a2s .c om*/