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.
Summary: | Enhance BeanTreeView to allow developers to set the row height | ||
---|---|---|---|
Product: | platform | Reporter: | jmborer <jmborer> |
Component: | Explorer | Assignee: | Jan Peska <JPESKA> |
Status: | NEW --- | ||
Severity: | normal | CC: | tboudreau |
Priority: | P3 | ||
Version: | 7.4 | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | ENHANCEMENT | Exception Reporter: |
Description
jmborer
2014-01-20 13:40:43 UTC
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(); } } ... } } |