Java JTable Row Height updateRowHeights(JTable table)

Here you can find the source of updateRowHeights(JTable table)

Description

update Row Heights

License

Open Source License

Declaration

public static void updateRowHeights(JTable table) 

Method Source Code

//package com.java2s;
/**/*from www. jav  a 2 s .com*/
 * Created by ekipogh on 12.05.2015.
 licensed under WTFPL
 */

import javax.swing.*;
import java.awt.*;

public class Main {
    public static void updateRowHeights(JTable table) {
        for (int row = 0; row < table.getRowCount(); row++) {
            int rowHeight = table.getRowHeight();

            for (int column = 0; column < table.getColumnCount(); column++) {
                Component comp = table.prepareRenderer(table.getCellRenderer(row, column), row, column);
                rowHeight = Math.max(rowHeight, comp.getPreferredSize().height);
            }

            table.setRowHeight(row, rowHeight);
        }
    }
}

Related

  1. getPreferredRowHeight(JTable table, int rowIndex, int margin)
  2. getRowBounds(JTable table, int row, int height)
  3. packRowHeights(final JTable table)
  4. platformTableRowHeight(JTable jtab, boolean forEdit)
  5. setRowHeight(JTable table, int row)