Article View: borland.public.jbuilder.java.api
Article #2684Re: READ PROPERTIES FROM COMPONENTS?
From: John P. McGrath
Date: Wed, 31 May 2000 00:00
Date: Wed, 31 May 2000 00:00
33 lines
1858 bytes
1858 bytes
On Tue, 30 May 2000 16:52:30 +0200, RenοΏ½ Thomsen wrote: > this is done with "panelname.getcomponent(int)" this also > works fine except the string returned from this function > dosent return all properties, only some. The string that you get is the result of the toString() method, which returns a string intended primarily for debugging. All of the public properties of components are available using the component's "getter" methods. For example, to get the background color for the component, you can use the getBackground() method. > how do i get the components name? its not in the property > string. What do you mean by the Component's "name". Are you referring to the name of the variable that the container class uses to reference the component, such as "jTextField1"? If this is what you mean, that variable name is not a property of the component, but of the container that holds it. There is no way to retrieve this from the component. In fact, it does not even have to exist. All components do have a property called "name", and you can get this using the getName() method and you can set it using setName(). But this is not the same as the variable name. If you mean the name of the components class (such as "JTextField"), you can get it using getClass().getName(). -- John P. McGrath <JPMcGrath@fast.net> <jpm@nscs.fast.net>
Technical Details
Message-ID:
<MPG.139e836de432c3a298996a@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<8h0k37$i0j1@bornews.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 1089d0,df8c540df255080 X-Google-Attributes: gid1089d0,public From: John P. McGrath <JPMcGrath@fast.net> Subject: Re: READ PROPERTIES FROM COMPONENTS? Date: 2000/05/31 Message-ID: <MPG.139e836de432c3a298996a@forums.borland.com> X-Deja-AN: 629363879 References: <8h0k37$i0j1@bornews.borland.com> Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.api