TableUtilities { public static int getPreferredRowHeight(JTable table, int row) { int pref = 0; for (int column = 0; column < table.getColumnCount(); column++) { TableCellRenderer renderer = table.getCellRenderer(row, column); Component comp = table.prepareRenderer(renderer, row, column); pref = Math.max(pref, comp.getPreferredSize().height); } return pref > 0 ? pref : table.getRowHeight(); } private  TableUtilities(); static boolean isDataChanged(TableModelEvent e); static boolean isUpdate(TableModelEvent e); static boolean isInsert(TableModelEvent e); static boolean isDelete(TableModelEvent e); static boolean isStructureChanged(TableModelEvent e); static int getPreferredRowHeight(JTable table, int row); static void setPreferredRowHeight(JTable table, int row); static void setPreferredRowHeights(JTable table); static int[] ordinalsOf(Enum<?>... values); static void clear(TableColumnModel model, boolean includeHidden);  }
@Test(expected = IndexOutOfBoundsException.class) public void testPrefRowHeightInvalidRow() { JTable table = new JTable(10, 3); assertEquals(table.getRowHeight(), TableUtilities.getPreferredRowHeight(table, -1)); }
@Test public void testZeroHeight() { JTable table = new JTable(); assertEquals(table.getRowHeight(), TableUtilities.getPreferredRowHeight(table, -1)); }
@Test (expected = NullPointerException.class) public void testPrefRowHeightMustBarkOnNull() { TableUtilities.getPreferredRowHeight(null, -1); }