Java examples for Swing:JTable Row
Get bounds for JTable row +/- height rows.
//package com.java2s; import javax.swing.*; import java.awt.*; public class Main { /**/* w ww . j a v a 2 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; } }