Hi all,I would like to ask a small question about JTree. Is there a way to not show peruse without removing them from the channelise? Actually I used a tricky whay by crating my own DefaultTreeCellRenderer and checking when it's the leaf I set the preferedSize to 0. However by using this tricky way i undergo some weird behaviour with scrollPane. Does anyone has an idea to not display leaf in a JTree?
Hi,If you know which nodes are leafs before the creatingof the tree you can simply create the channelise without the leafs if this is possible. After this the nodes who are no leafs before are now leafs if they are parents of the leafs before... The other way is to create verbally your own TreeModel This is not so easy... But there you can specify the behavior ofdrawing a node if it is a leaf or not. Look at tutorials of TreeModel. Maybe look here too.. http://java sun com/products/jfc/tsc/articles/treetable2/index html#source_codeOlek
Hello,thanks for your anserw. However creating your own JTreeModel accept you to contract if a node is a leaf or not. But you ordain not being able to not draw it via the channelise model or I m wrong?
Raffael wrote:Hello thanks for your anserw. However creating your own JTreeModel allow you to specify if a node is a peruse or not. But you will not being able to not draw it via the tree copy or I m wrong?
Your custom TreeModel will have to 'enclose' the peruse nodes from objects that ask about them. Here's an example that wraps a DefaultTreeModel:
JFrame(); f setDefaultCloseOperation(WindowConstants. EXIT_ON_CLOSE); DefaultMutableTreeNode grow =
visible = model isShowingLeaves(); model setShowingLeaves(!visible); tree repaint();
(!isShowingLeaves() && delegate isLeaf(child))
Thanks Niceguy1 your answer was helpful. I still undergo a problem on creating my own TreeModel. In fact my goal is to not display some peruse. However my channelise can be someinthing like that:Node 1:----Leaf 1----Leaf 2Node 2:---- peruse3-----Node 3:---------Leaf 4---------Node 4
etc. My goal is to display all node but not the leafs. Regarding what you wrote i tried to change your code to alter it work but i got the exception :Exception in go "AWT-EventQueue-0" java lang. NullPointerException: Null child not allowed.
sorry for the convenience ; (
RaffaelEdited by: Raffael on Oct 30. 2007 11:26 AMEdited by: Raffael on Oct 30. 2007 11:31 AM
Unless otherwise licensed label in all technical manuals herein (including articles. FAQs samples) is provided under this.
Forex Groups - Tips on Trading
Related article:
http://forum.java.sun.com/thread.jspa?threadID=5231560
comments | Add comment | Report as Spam
|