Article View: borland.public.jbuilder.java.swing
Article #1562Adding a nodes to a tree in expanded state
From: L Redmond
Date: Fri, 10 Oct 2003 15:35
Date: Fri, 10 Oct 2003 15:35
63 lines
3042 bytes
3042 bytes
I have a node which has child nodes and i would like to add it to a jtree in expanded state. How can this be done. Right now when I add it to root it it collapsed. I have tried the following but I get the follwoing exception .... String[] path = =new String[2]; path[0] = "MYROOT" path[1] = "MyNode" TreePath p = new TreePath(path); tree.expandPath(p); //this is the line at for the following exception at mypackage1.CommTree.expandNewNode(CommTree.java:1437) Any Ideas? -----here is the exception --- java.lang.ClassCastException at javax.swing.tree.DefaultTreeModel.isLeaf(DefaultTreeModel.java:185) at javax.swing.JTree.expandPath(JTree.java:1746) at mypackage1.CommTree.expandNewNode(CommTree.java:1437) at mypackage1.CommTree.AddCommentary(CommTree.java:1151) at mypackage1.CommTree.commTypeList_mouseClicked(CommTree.java:1081) at mypackage1.CommTree$24.mouseClicked(CommTree.java:1056) at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:208) at java.awt.Component.processMouseEvent(Component.java:5137) at java.awt.Component.processEvent(Component.java:4931) at java.awt.Container.processEvent(Container.java:1566) at java.awt.Component.dispatchEventImpl(Component.java:3639) at java.awt.Container.dispatchEventImpl(Container.java:1623) at java.awt.Component.dispatchEvent(Component.java:3480) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3174) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095) at java.awt.Container.dispatchEventImpl(Container.java:1609) at java.awt.Component.dispatchEvent(Component.java:3480) at java.awt.EventQueue.dispatchEvent(EventQueue.java:450) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136) at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
Technical Details
Message-ID:
<3f86d1ac$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!irazu.switch.ch!switch.ch!news.belwue.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,c2be3d8836cc108a,start X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2003-10-10 08:39:33 PST From: "L Redmond" <lredmond@bn.com> Sender: "L Redmond" <lredmond@bn.com> Reply-To: "L Redmond" <lredmond@bn.com> Subject: Adding a nodes to a tree in expanded state Newsgroups: borland.public.jbuilder.java.swing X-User-Info: 63.148.27.236 NNTP-Posting-Host: 207.105.83.66 Message-ID: <3f86d1ac$1@newsgroups.borland.com> Date: 10 Oct 2003 08:35:08 -0700 X-Trace: newsgroups.borland.com 1065800108 207.105.83.66 (10 Oct 2003 08:35:08 -0700) Lines: 65 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!irazu.switch.ch!switch.ch!news.belwue.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail