Java JTable Row Height correctRowHeight(JTable table)

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

Description

Update table row height to the best possible considering font size changes on the current platform http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4760081

License

Open Source License

Parameter

Parameter Description
table a parameter

Declaration

public static void correctRowHeight(JTable table) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.FontMetrics;
import javax.swing.JTable;
import javax.swing.JTree;

public class Main {
    /**//from   w w  w. j av  a 2 s  . co  m
     * Update table row height to the best possible considering font size changes on the current platform
     *
     * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4760081
     *
     * @param table
     */
    public static void correctRowHeight(JTable table) {
        // Fix tree row height
        FontMetrics metrics = table.getFontMetrics(table.getFont());
        table.setRowHeight(Math.max(table.getRowHeight(), metrics.getHeight()));
    }

    /**
     * Update tree row height to the best possible considering font size changes on the current platform
     *
     * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4760081
     *
     * @param table
     */
    public static void correctRowHeight(JTree tree) {
        // Fix tree row height
        FontMetrics metrics = tree.getFontMetrics(tree.getFont());
        tree.setRowHeight(Math.max(tree.getRowHeight(), metrics.getHeight()));
    }
}

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)