🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #1564

Re: Adding a nodes to a tree in expanded state

#1564
From: lredmond
Date: Sat, 11 Oct 2003 06:00
85 lines
3600 bytes
Found the Solution, The constructor for TreePath in the docs accepts an
array of Objects[], which is invalid, it takes TreeNode[], so when I use the
following

TreePath path = new TreePath(myNode.getPath);
tree.expandPath(path);

it worked.


"L Redmond" <lredmond@bn.com> wrote in message
news:3f86d1ac$1@newsgroups.borland.com...
>
> 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.ja
va: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: <3f879c86$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!news02.tsnz.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3f86d1ac$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,c2be3d8836cc108a
X-Google-Attributes: gid111d45,public
X-Google-ArrivalTime: 2003-10-10 23:03:29 PST
From: "lredmond" <lredmond@nyc.rr.com>
Newsgroups: borland.public.jbuilder.java.swing
References: <3f86d1ac$1@newsgroups.borland.com>
Subject: Re: Adding a nodes to a tree in expanded state
Date: Sat, 11 Oct 2003 02:00:36 -0400
Lines: 87
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 24.90.154.160
Message-ID: <3f879c86$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1065852038 24.90.154.160 (10 Oct 2003 23:00:38 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!news02.tsnz.net!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail