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.
We had an interesting thread exchange (http://forums.netbeans.org/topic58517.html) I would like an enhancement of TreeView allowing me to override ExplorerTree.calcRowHeight() implementation. A solution would be that calcRowHeight() of the inner ExplorerTree class calls a another overridable method in TreeView. This own, by default, returns the default implementation. I am not expecting this method to be invoked for each row. This would allow me to adapt the row height at runtime and not beeing stuck with a system property that is read once at initialization of the VM and applies to all TreeViews. A simple warning to the developer, that returning 0 in size method could have a serious performance impact would be fine IMHO, but at least you leave the decision to her/him. I am thinking about something like... public class TreeView { protected int getDefaultRowHeight(Graphics g) { return Math.max(18, 2 + g.getFontMetrics(getFont()).getHeight()); } private final class ExplorerTree extends JTree implements Autoscroll, QuickSearch.Callback { private void calcRowHeight(Graphics g) { // patch here int height = getDefaultRowHeight(Graphics g); // end patch //Issue 42743/"Jesse mode" String s = System.getProperty("nb.cellrenderer.fixedheight"); //NOI18N if (s != null) { try { height = Integer.parseInt(s); } catch (Exception e) { //do nothing, height not changed } } if (getRowHeight() != height) { setRowHeight(height); } else { revalidate(); repaint(); } } } I am convinced that overriding ExplorerTree.calcRowHeight() would have no impact on performance, but would be a great improvement when using TreeViews with custom renderers.
Here is another alternative for setting configurable row height for Tree that won't affect the code structure. It uses client property: public class TreeView { protected int getDefaultRowHeight(Graphics g) { return Math.max(18, 2 + g.getFontMetrics(getFont()).getHeight()); } private final class ExplorerTree extends JTree implements Autoscroll, QuickSearch.Callback { ... private void calcRowHeight(Graphics g) { int height = Math.max(18, 2 + g.getFontMetrics(getFont()).getHeight()); Object o = super.getClientProperty("row.height"); if (o != null && o instanceof Number) { height = Number.class.cast(o).intValue(); } //Issue 42743/"Jesse mode" String s = System.getProperty("nb.cellrenderer.fixedheight"); //NOI18N if (s != null) { try { height = Integer.parseInt(s); } catch (Exception e) { //do nothing, height not changed } } if (getRowHeight() != height) { setRowHeight(height); } else { revalidate(); repaint(); } } ... } }