🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: CellEditor for JTree Nodes

#9490
From: John P. McGrath
Date: Tue, 28 Mar 2000 00:00
31 lines
1947 bytes
On Mon, 27 Mar 2000 00:05:08 -0500, Mustapha Essalihe wrote:

> Using a different DefaultCellEditors for JTree Nodes with
> JTree.setCellEditor(DefaultCellEditor)  give me a problem
> with a TreeSelectionListener event, the actual node selected
> take in memory the last DefaultCellEditor affected to JTree
> with the last execution of JTree.setCellEditor(DefaultCellEditor)
> There is another way to use CellEditor for a JTree Nodes ?

Are you trying to use a different TreeCellEditor for different nodes?  
JTree only allows you to set a single TreeCellEditor for the entire tree.  
This is different than JTable, which allows you to set a different cell 
editor for each column.  JTree has no columns" or other obvious criteria 
to use to select the TreeCellEditor.

One way to deal with this would be to implement a custom TreeNode class, 
and give it a getCellEditor() method which returns an appropriate 
CellEditor for the given node.  Then write a CellEditor for the entire 
tree that gets uses the TreeNode getCellEditor() method to get the editor 
for the node, and invokes it.

Another way would be to write a TreeCellEditor that looks at the current 
node, determines what sort of editing component is needed, and returns 
the appropriate component for the current node.  This is somewhat less 
object oriented, but depending on your code, it may be a reasonable way 
to handle it.

-- 
John P. McGrath
<JPMcGrath@fast.net>
<jpm@nscs.fast.net>
Technical Details
Message-ID: <MPG.134a164119f7b780989831@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <38DEEC04.BFD0CF6E@iro.umontreal.ca>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,640076f905710e6b
X-Google-Attributes: gid111d45,public
From: John P. McGrath <JPMcGrath@fast.net>
Subject: Re: CellEditor for JTree Nodes
Date: 2000/03/28
Message-ID: <MPG.134a164119f7b780989831@forums.borland.com>
X-Deja-AN: 603284968
References: <38DEEC04.BFD0CF6E@iro.umontreal.ca>
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.swing