Scroll JTable to Show cell. - Java Swing

Java examples for Swing:JTable Scroll

Description

Scroll JTable to Show cell.

Demo Code


import java.awt.Rectangle;
import java.util.Collections;
import java.util.Comparator;
import java.util.Vector;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import org.apache.log4j.Logger;

public class Main{
    /**//from   w  ww . java  2  s  . com
     * Show cell.
     * 
     * @param table the table
     * @param row the row
     * @param column the column
     */
    public static void showCell(JTable table, int row, int column) {
        Rectangle rect = table.getCellRect(row, column, true);
        table.scrollRectToVisible(rect);
        table.clearSelection();
        table.setRowSelectionInterval(row, row);
    }
}

Related Tutorials