Java JTable Row Height getRowBounds(JTable table, int row, int height)

Here you can find the source of getRowBounds(JTable table, int row, int height)

Description

Get bounds for row +/- height rows.

License

Open Source License

Parameter

Parameter Description
table Table
row Row
height Height

Declaration

public static Rectangle getRowBounds(JTable table, int row, int height) 

Method Source Code


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

import javax.swing.*;
import java.awt.*;

public class Main {
    /**/*from  w  w  w  . ja  v  a2 s .c  om*/
     * Get bounds for row +/- height rows.
     *
     * @param table Table
     * @param row Row
     * @param height Height
     */
    public static Rectangle getRowBounds(JTable table, int row, int height) {
        int first = Math.max(0, row - height);
        int last = Math.min(table.getRowCount() - 1, row + height);

        Rectangle result = table.getCellRect(first, -1, true);
        result = result.union(table.getCellRect(last, -1, true));
        Insets i = table.getInsets();

        result.x = i.left;
        result.width = table.getWidth() - i.left - i.right;

        return result;
    }
}

Related

  1. correctRowHeight(JTable table)
  2. getPreferredRowHeight(JTable table, int rowIndex, int margin)
  3. packRowHeights(final JTable table)
  4. platformTableRowHeight(JTable jtab, boolean forEdit)
  5. setRowHeight(JTable table, int row)
  6. updateRowHeights(JTable table)