NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
lakshman_br
Joined: 12 Aug 2009 Posts: 2
|
Posted: Wed Aug 12, 2009 8:28 am Post subject: How to use cellrenderer for JTree using netbeans. |
|
|
Hi All,
I have created a frame and in which i have placed a panel which contain the JTree.
Netbeans generate the code for alignment etc...and will be called in constructor. so to fill the tree with my data/nodes i have used the below code.
fileView = new javax.swing.JTree(fileNode);
treeScrollPane.setViewportView(fileView);
I also want to change the icons of the tree notes (root and child) based on a condition so i have created a instance of TreeRenderer (tr) (custom code which extends DefaultTreeCellRenderer, contains getTreeCellRendererComponent also) and the same is set for the tree before calling set visible.
treeView.getSelectionModel().setSelectionMode(javax.swing.tree.TreeSelectionModel.SINGLE_TREE_SELECTION);
treeView.addTreeSelectionListener(this);
TreeRenderer tr = new TreeRenderer();
treeView.setCellRenderer(tr);
I am able to see that my data is populated in tree as nodes but the tree is not renderered.
it is displayed as normal tree.
Could you please help me in this and how to use cellrenderer for JTree in Netbeans. |
|
| Back to top |
|
 |
lakshman_br
Joined: 12 Aug 2009 Posts: 2
|
Posted: Thu Aug 13, 2009 4:35 am Post subject: |
|
|
Hi all,
any inputs on this please. |
|
| Back to top |
|
 |
Thomas Wolf Posted via mailing list.
|
Posted: Thu Aug 13, 2009 1:00 pm Post subject: How to use cellrenderer for JTree using netbeans. |
|
|
...the same way you would use cell renderers without netbeans...here's
the java tutorial:
http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html#display
tom
On 08/13/2009 12:35 AM, lakshman_br wrote:
| Quote: | Hi all,
any inputs on this please.
| **********************************************************************************************
IMPORTANT: The contents of this email and any attachments are confidential. They are intended for the
named recipient(s) only.
If you have received this email in error, please notify the system manager or the sender immediately and do
not disclose the contents to anyone or make copies thereof.
*** eSafe scanned this email for viruses, vandals, and malicious content. ***
********************************************************************************************** |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|