🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #14534

instantiating from a class name

#14534
From: Steve Grant
Date: Mon, 30 Aug 1999 00:00
13 lines
1530 bytes
I'd like to be able to build a JTree using models that are loaded by
passing the model name.  The basic idea is to instantiate an instance
variable of the interface that all the models implement in a separate
class, and then use the interface methods to build the tree without ever
knowing in advance which tree will be built. My problem is that I can't
seem to use the (interface)Class.forname("classname").newInstance() and
get anything other than null. The other complication is that the models
take parameters but I think I could handle this with a separate
interface function as opposed to through a constructor. My thought was
that if I have trees which can take variable models it would good
practice to make those trees pluggable. I would appreciate any help on
how to use the forname/instanceof construction or if I 've got something
wrong in how I'm conceving this. Thanks.
Technical Details
Message-ID: <37CA93AC.C3877419@well.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,62b39a9dceca75bd,start
X-Google-Attributes: gid111d45,public
X-Google-Thread: f74b3,62b39a9dceca75bd,start
X-Google-Attributes: gidf74b3,public
From: Steve Grant <sgrant@well.com>
Subject: instantiating from a class name
Date: 1999/08/30
Message-ID: <37CA93AC.C3877419@well.com>
X-Deja-AN: 518880408
Content-Transfer-Encoding: 7bit
Organization: Another Netscape Collabra Server User
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language,borland.public.jbuilder.java.swing