Top.Mail.Ru
August 29th, 2004 - Java developers — LiveJournal
? ?

Java developers

August 29th, 2004

05:12 pm - sparkymark - JTree cells

I have seen this problem mentioned in the Usenet archive periodically from 1998-2004 but have not seen an easy solution i.e. a solution other than implementing a TreeCellRenderer.

When the text of a cell of a JTree becomes longer, as a result of that tree's event handler calling treeStructureChanged, then only text up to the previous length of the cell's text is displayed.

More...Collapse )
Edit: Extending DefaultTreeCellRenderer so that getTreeCellRendererComponent calls its "super" and then setPreferredSize on the object it returns (cast as JLabel), does most of the job, but the Dimension I used for setPreferredSize is arbitrarily large and so causes an unsightly blob of space at the end of the cell when it is highlighted. Is there a way to set the Dimensions of a JLabel so that it only just fits its text: presumably exactly this is happening somewhere in the bowels of DefaultTreeCellRenderer when the cell is initially rendered?

06:57 pm - banana - RE performance

Java quicker than Perl at regular expressions? Who'd have thought it?
Powered by LiveJournal.com