This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
import java.awt.Font;
import java.awt.FontMetrics;
import javax.swing.UIManager;
import javax.swing.*;
import javax.swing.JTable;
import org.netbeans.modules.xml.core.lib.AbstractUtil;
* Calculate JTable cell height for textual rows.
*/
public static int getTextCellHeight(JTable table) {
Font cellFont = UIManager.getFont("TextField.font"); // NOI18N
JComboBox template = new JComboBox();
if (cellFont != null) {
return template.getPreferredSize().height;
FontMetrics fm = table.getFontMetrics(cellFont);
if (fm != null) {
return fm.getHeight() + 2;
}
return 16;