Example usage for javax.swing JViewport getViewPosition

List of usage examples for javax.swing JViewport getViewPosition

Introduction

In this page you can find the example usage for javax.swing JViewport getViewPosition.

Prototype

public Point getViewPosition() 

Source Link

Document

Returns the view coordinates that appear in the upper left hand corner of the viewport, or 0,0 if there's no view.

Usage

From source file:xtrememp.PlaylistManager.java

public void makeRowVisible(int rowIndex) {
    if (!(playlistTable.getParent() instanceof JViewport)) {
        return;/* w  w w.j a  va  2  s  .c  o m*/
    }
    JViewport viewport = (JViewport) playlistTable.getParent();
    Rectangle contentRect = (Rectangle) playlistTable
            .getCellRect(rowIndex, playlistTable.getSelectedColumn(), true).clone();
    Point pt = viewport.getViewPosition();
    contentRect.setLocation(contentRect.x - pt.x, contentRect.y - pt.y);
    viewport.scrollRectToVisible(contentRect);
}