Article View: borland.public.jbuilder.java.swing
Article #12394Setting a TreeModel
From: Leo Cohen
Date: Thu, 07 Jan 1999 00:00
Date: Thu, 07 Jan 1999 00:00
32 lines
1453 bytes
1453 bytes
In the following code I set a TreeModel:
viewTree = new JTree(root);
mdl = new ViewTreeModel(st, path);
viewTree.setModel(mdl);
This compiles, but on running it I get ClassCastException. This occurs
in JTree.setModel() when it calls the method firePopertyChange(), which
in turn is trying to execute the getChildren() method in my TreeModel
interface.
getChildren() accepts an Object, and in my implementation I cast it to
ContextObject - my own construct - and send it off to a method in a
class that knows how to get children. It is on this cast that I get the
run time exception.
The question is, why is setModel() [ via firePropertyChange() ] calling
anything in my TreeModel interface?
The second question is, since this is how it works, what do I do about
it?
--
Leo Cohen
116-1 Howard Drive
Charlottesville, VA 22903
804-243-8922 (UVA)
804-244-4648 (home)
804-244-7922 (fax)
lcohen@cs.virginia.edu
Technical Details
Message-ID:
<369515EB.39EDA25C@cs.virginia.edu>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,8bf121a970650ffe,start X-Google-Attributes: gid111d45,public From: Leo Cohen <lcohen@cs.virginia.edu> Subject: Setting a TreeModel Date: 1999/01/07 Message-ID: <369515EB.39EDA25C@cs.virginia.edu> X-Deja-AN: 429917336 Content-Transfer-Encoding: 7bit Organization: Another Netscape Collabra Server User Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.swing