public void scrollCellToView(JTable table, int rowIndex, int vColIndex) {
        if (!(table.getParent() instanceof JViewport)) {
            return;
        }
        JViewport viewport = (JViewport) table.getParent();
        Rectangle rect = table.getCellRect(rowIndex, vColIndex, true);
        Rectangle viewRect = viewport.getViewRect();

        int x = viewRect.x;
        int y = viewRect.y;

        if (rect.x >= viewRect.x && rect.x <= (viewRect.x + viewRect.width - rect.width)){

        } else if (rect.x < viewRect.x){
            x = rect.x;
        } else if (rect.x > (viewRect.x + viewRect.width - rect.width)) {
            x = rect.x - viewRect.width + rect.width;
        }

        if (rect.y >= viewRect.y && rect.y <= (viewRect.y + viewRect.height - rect.height)){

        } else if (rect.y < viewRect.y){
            y = rect.y;
        } else if (rect.y > (viewRect.y + viewRect.height - rect.height)){
            y = rect.y - viewRect.height + rect.height;
        }
        viewport.setViewPosition(new Point(x,y));
    }