Java JTree correctRowHeight(JTree tree)

Here you can find the source of correctRowHeight(JTree tree)

Description

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

License

Open Source License

Parameter

Parameter Description
table a parameter

Declaration

public static void correctRowHeight(JTree tree) 

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  ww  w.  j av  a  2  s  .c o 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. applyDefaultProperties(final JTree comp)
  2. autoscroll(JTree tree, Point cursorLocation)
  3. autoScrollIsDesirable(JTree tree)
  4. clearTreeIcon(JTree tree)
  5. disposeExpressionsTree()
  6. enableAutoExpansion(final JTree tree)
  7. findByName(JTree tree, String[] names)
  8. findTree(Container container)