Java JTable Scroll scrollToVisible(final JTable table, final int rowIndex, final int vColIndex)

Here you can find the source of scrollToVisible(final JTable table, final int rowIndex, final int vColIndex)

Description

scroll To Visible

License

Open Source License

Declaration

public static void scrollToVisible(final JTable table, final int rowIndex, final int vColIndex) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Point;
import java.awt.Rectangle;
import javax.swing.JViewport;
import javax.swing.JTable;

public class Main {
    public static void scrollToVisible(final JTable table, final int rowIndex, final int vColIndex) {
        if (!(table.getParent() instanceof JViewport)) {
            return;
        }/*from www .  j av a  2s.  com*/
        final JViewport viewport = (JViewport) table.getParent();
        final Rectangle rect = table.getCellRect(rowIndex, vColIndex, true);
        final Point pt = viewport.getViewPosition();
        rect.setLocation(rect.x - pt.x, rect.y - pt.y);
        viewport.scrollRectToVisible(rect);
    }
}

Related

  1. scrollToLastSelectedRow(final JTable table)
  2. scrollToPosition(JTable table, int insertRow)
  3. scrollToRow(JTable table, int row)
  4. scrollToSelectedRow(JTable table)
  5. scrollToTableCell(JTable table, int rowIndex, int colIndex)
  6. scrollToVisible(final JTable table, final int rowIndex, final int vColIndex)
  7. scrollToVisible(final JTable table, int rowIndex, int vColIndex)
  8. scrollToVisible(JTable table, int row, int col)
  9. scrollToVisible(JTable table, int row, int col)