Home arrow static arrow Java Programming [Archive] - retrieving name of swing components
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - retrieving name of swing components
This topic has 1 reply on 1 page.

Posts:8
Registered: 6/16/04
retrieving name of swing components  
Jun 17, 2004 3:41 PM



 
Hello all: I am working on a form application in which a doctor can select several drugs to prescribe to a patient. There are 38 drugs we commonly use, so each line of the form is for a seperate drug. Each drug has multiple radio buttons and check boxes.

Now, I do not want to go thru the hassle of customizing each component to match the drug it represents since there are 38 *9 components. What I thought would work is to give each component for the same drug the same name (internal name) not object name. I could then read the name, look up the correct info and fill in the correct text of the form. For example, I have a checkbox for each prescription with object names of pscriptCkechBox1, 2, 3 .... Internal to these objects is the name variable and the text varible. For all I can tell the text variable is what is read when the component is drawn. So, rather than typing all this in, I would just ask the component what drug it represents (the internal name variable), lookup the correct text, and set the text variable accordingly. So, one function call to get the name, and a second to put it in correctly.

While looking into this, I noticed in Netbeans, the ide I am using, you can custom program the swing objects to do precisely this - I just don't know exactly how. All attempts have either resulted in blank text or a return of the frame name.

Hope this question makes sense, Chris.
 

Posts:2,206
Registered: 8/15/02
Re: retrieving name of swing components  
Jun 17, 2004 4:57 PM (reply 1 of 1)



 
I am a little... no, a lot... confused by your post. Are you saying you want something like this
myJComponent.setName("fred");


this is trivial, so I don't believe this is what you are looking for.
 
This topic has 1 reply on 1 page.