Java Utililty Methods JTable Row Visible

List of utility methods to do JTable Row Visible

Description

The list of methods to do JTable Row Visible are organized into topic(s).

Method

doublecomputeVisibleRowsCount(JTable table)
Returns the number of visible rows in the given table.
return table.getParent().getBounds().getHeight() / table.getRowHeight();
voidensureRowVisible(JTable table, int row)
ensure Row Visible
Rectangle r = table.getVisibleRect();
Rectangle rMid = table.getCellRect(row, 0, true);
Rectangle rBefore = null;
Rectangle rAfter = null;
if (row < table.getModel().getRowCount() - 1)
    rAfter = table.getCellRect(row + 1, 0, true);
if (row > 0) {
    rBefore = table.getCellRect(row - 1, 0, true);
...
voidensureRowVisible(JTable table, int row)
To make sure the row is visible.
Rectangle r = table.getVisibleRect();
Rectangle rMid = table.getCellRect(row, 0, true);
Rectangle rBefore = null, rAfter = null;
if (row < table.getModel().getRowCount() - 1)
    rAfter = table.getCellRect(row + 1, 0, true);
if (row > 0)
    rBefore = table.getCellRect(row - 1, 0, true);
int yLow = (int) rMid.getMinY();
...
intgetFirstVisibleRow(JTable p_Table)
get First Visible Row
Point p = p_Table.getVisibleRect().getLocation();
return p_Table.rowAtPoint(p);
intgetFirstVisibleRowIndex(JTable table)
Returns the row index of the last visible row.
ComponentOrientation or = table.getComponentOrientation();
Rectangle r = table.getVisibleRect();
if (!or.isLeftToRight()) {
    r.translate((int) r.getWidth() - 1, 0);
return table.rowAtPoint(r.getLocation());
intgetLastVisibleRow(JTable p_Table)
get Last Visible Row
Point p = p_Table.getVisibleRect().getLocation();
p.y = p.y + p_Table.getVisibleRect().height - 1;
int result = p_Table.rowAtPoint(p);
if (result > 0)
    return result;
if (p_Table.getVisibleRect().height > 0)
    return p_Table.getRowCount() - 1;
else
...
intgetLastVisibleRow(JTable p_Table)
get Last Visible Row
Point p = p_Table.getVisibleRect().getLocation();
p.y = p.y + p_Table.getVisibleRect().height - 1;
int result = p_Table.rowAtPoint(p);
if (result > 0) {
    return result;
if (p_Table.getVisibleRect().height > 0) {
    return p_Table.getRowCount() - 1;
...
intgetLastVisibleRowIndex(JTable table)
Returns the row index of the last visible row.
ComponentOrientation or = table.getComponentOrientation();
Rectangle r = table.getVisibleRect();
r.translate(0, (int) r.getHeight() - 1);
if (or.isLeftToRight()) {
    r.translate((int) r.getWidth() - 1, 0);
if (table.rowAtPoint(r.getLocation()) == -1) {
    if (getFirstVisibleRowIndex(table) == -1) {
...
intgetLeadingRow(JTable table, Rectangle visibleRect)
get Leading Row
return table.rowAtPoint(getLeadingPoint(table, visibleRect));
intgetVisibleRowCount(JTable list)
get Visible Row Count
Rectangle visibleRect = list.getVisibleRect();
return getTrailingRow(list, visibleRect) - getLeadingRow(list, visibleRect) + 1;