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

voidmakeRowVisible(JTable table, int row)
Make the given row in the table visible
Rectangle cellRect = table.getCellRect(row, 0, true);
if (cellRect != null) {
    table.scrollRectToVisible(cellRect);
voidsetupTableUI(JTable table, int visibleRows)
setup Table UI
table.setPreferredScrollableViewportSize(new Dimension(table.getPreferredScrollableViewportSize().width,
        table.getRowHeight() * visibleRows));
Font font = table.getFont();
table.setRowHeight(table.getFontMetrics(font).getHeight() + 5);
voidsetVisibleRowCount(final JTable table, final int rows)
Set the preferred viewport size on a table based upon the number of rows that should be visible and the current heights of the rows.
int height = 0;
for (int row = 0; row < rows; row++) {
    height += table.getRowHeight(row);
table.setPreferredScrollableViewportSize(
        new Dimension(table.getPreferredScrollableViewportSize().width, height));
voidsetVisibleRowCount(final JTable table, final int rows)
Sizes the table to number of rows using getRowHeight
if (table != null) {
    table.setPreferredScrollableViewportSize(
            new Dimension(table.getPreferredScrollableViewportSize().width, rows * table.getRowHeight()));