Java Utililty Methods JTable Row

List of utility methods to do JTable Row

Description

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

Method

Object[]getNullRow(TableModel tm)
get Null Row
Object[] row = new Object[tm.getColumnCount()];
return row;
intgetReadableRow(JTable table, int maximumHiddenPart)
get Readable Row
Rectangle visibleRect = table.getVisibleRect();
Point leadingPoint = getLeadingPoint(table, visibleRect);
int row = table.rowAtPoint(leadingPoint);
int column = table.columnAtPoint(leadingPoint);
if (leadingPoint.y - table.getCellRect(row, column, true).getY() <= maximumHiddenPart) {
    return row;
} else {
    return Math.min(row + 1, table.getRowCount() - 1); 
...
intgetRealRowPos(int rowPos, JTable table)
get Real Row Pos
if (rowPos == -1) {
    return rowPos;
if (table.getRowSorter() == null) {
    return rowPos;
int fixRowPos = table.getRowSorter().convertRowIndexToModel(rowPos);
return fixRowPos;
...
RectanglegetRowBounds(JTable table, int first, int last)
get Row Bounds
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;
intgetRowByValue(TableModel model, Object value)
get Row By Value
for (int i = model.getRowCount() - 1; i >= 0; --i) {
    for (int j = model.getColumnCount() - 1; j >= 0; --j) {
        if (model.getValueAt(i, j).equals(value)) {
            return i;
return 0;
...
Object[]getTableRow(TableModel tableModel, int row)
Returns all cell values of a given table row ordered by their column indexes.
int columnCount = tableModel.getColumnCount();
Object[] rowData = new Object[columnCount];
for (int ct = 0; ct < columnCount; ct++)
    rowData[ct] = tableModel.getValueAt(row, ct);
return rowData;
booleanhasRows(JTable table)
has Rows
TableModel model = table.getModel();
if ((model.getRowCount() > 0) && (!firstRowIsVoid(model))) {
    return true;
return false;
voidinsertRow(final JTable table, final int index, Object... data)
insert Row
((DefaultTableModel) table.getModel()).insertRow(index, data);
booleanisFirstToLastRow(TableModelEvent e)
is First To Last Row
return e.getFirstRow() == 0 && e.getLastRow() == MAX_VALUE;
booleanisRowInsert(TableModelEvent e)
is Row Insert
return (e.getType() == TableModelEvent.INSERT && e.getFirstRow() >= 0);