JTree cell size problem

Hi! ,

I have a JTree displayed within a JScrollPane. The JTree has a custom renderer, whose

GetTreeCellRendererComponent method return different objects (depending on the node).

One of the objects returned is a JEditorPane. When a node of this type is expanded Id like the JEditorPane to be shown at it s preferred size and not be limited to a tree cell size (i.e.- I'd like the cell size to change for this specific node based on the editor's preferred size). The user will have to scroll down the tree in order to view the text or the nodes bellow.

My problem is I am unable to control the size of the tree cell. I manage to show either all of text in one line using only the main horizontal scroll, orin one (very long) column (whos width is the width of the longest text element) using only the vertical scroll. I am unable to change both width & height of the cell! .

Setting the editor s preferred size does not help.

Please note: the trees row height is set to 1.

Any suggestions? .

Thanks! .

[1075 byte] By [InbarOron] at [2007-9-26 1:29:04]
# 1

Return the size of your editor pane in customized cell renderer's getPreferredSize() method and set JTree rowHeight to zero. When row height is 0, it use renderer's getPreferredSize() to get size of the cell, I think. I have made custom cellrenderer which extends Jpanel and in getCellRendererComponent I add there another panel which contains buttons etc. I have used super.getPreferredSize() in my renderer's getPreferredSize() method.

eseppala at 2007-6-29 1:15:47 > top of Java-index,Archived Forums,Swing...
# 2
Heh, should have looked the year also..
eseppala at 2007-6-29 1:15:47 > top of Java-index,Archived Forums,Swing...