🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: JTree of objects other than String but displaying String, possible?

#11497
From: Sjaak Wolfert
Date: Thu, 27 May 1999 00:00
16 lines
1079 bytes
Jabber,

You should override the toString() method in MyObject and return the string
you like.

Sjaak

Jabber wrote in message <374C580D.635E4D78@tiac.net>...
>I am trying to create a JTree of my own defined objects, rather than
>Strings. This in itself is easy:
>    child = new DefaultMutableTreeNode(new MyObject);
>    parent.add(child);
>However, I would like to see a String attribute of MyObject as the label
>for the node in the tree, rather than the MyObject.toString(); of it. Is
>there a way to do this?
>
Technical Details
Message-ID: <7iirg9$3hp3@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <374C580D.635E4D78@tiac.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,7b988e188e65d939
X-Google-Attributes: gid111d45,public
From: "Sjaak Wolfert" <sjaak.wolfert@users.info.wau.nl>
Subject: Re: JTree of objects other than String but displaying String, possible?
Date: 1999/05/27
Message-ID: <7iirg9$3hp3@forums.borland.com>
X-Deja-AN: 482627388
References: <374C580D.635E4D78@tiac.net>
Organization: Another Netscape Collabra Server User
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0
Newsgroups: borland.public.jbuilder.java.swing