Article View: borland.public.jbuilder.java.language
Article #16880JTree listeners
From: Leo Cohen
Date: Tue, 12 Jan 1999 00:00
Date: Tue, 12 Jan 1999 00:00
31 lines
1380 bytes
1380 bytes
I am trying to add a JTree listener to my program. The code
JTree viewTree = new JTree();
TreeModel mdl = new ViewTreeModel(st, root);
viewTree.setModel(mdl);
mdl.addTreeModelListener(?);
needs a parameter for the addTreeModelListener() call. JTree has the
line JTree.this.getModel().addTreeModelListener(this); in the method
AccessibleJTree() within the AccessibleJTree class.
Question: since the proper form for
addTreeModelListener(TreeModelListener tml) includes a parameter as
shown, why does addTreeModelListener(this) work in JTree class when this
refers to JTree (or AccessibleJTree)?
I get a compiler error when I mimick this code with the line
mdl.addTreeModelListener(viewTree);
--
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:
<369BA4EA.A1D99B54@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: f74b3,d0d912cc934860da,start X-Google-Attributes: gidf74b3,public From: Leo Cohen <lcohen@cs.virginia.edu> Subject: JTree listeners Date: 1999/01/12 Message-ID: <369BA4EA.A1D99B54@cs.virginia.edu> X-Deja-AN: 431774447 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.language