Article View: borland.public.jbuilder.java.language
Article #15519Need Help
From: Ed
Date: Thu, 03 Jun 1999 00:00
Date: Thu, 03 Jun 1999 00:00
32 lines
1484 bytes
1484 bytes
I have an applet with 5 checkboxes, and a text field. I wanted the
textbox to show which checkbox was clicked. I first tried to get this
the long way:
if ( e.getItemSelectable() == checkbox1 ) {
text1.setText( "Check Box 1 Clicked" );
...
etc.
I then realized that I should be able to create a checkbox to hold the
currently selected item:
public void itemStateChanged( ItemEvent e ) {
Checkbox hold;
hold = (Checkbox) e.getItemSelectable();
text1.setText( hold.getLabel() + " was clicked." );
}
This code worked fine. I am having a problem when I ask for the
components name:
hold = (Checkbox) e.getItemSelectable();
text1.setText( hold.getName() + " was clicked." );
This returns checkbox0 for the first checkbox clicked (doesn't matter
which one is chosen first) and then checkbox1 for the next, and so on.
My question is (finally) why doesn't the getName() give me the
"correct" answer. The getLabel() works correctly.
Thanks
Ed
Technical Details
Message-ID:
<3757b77d.14818678@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,38e75a1cc4399d93,start X-Google-Attributes: gidf74b3,public From: dunphy.eg@buckconsultants.com (Ed) Subject: Need Help Date: 1999/06/03 Message-ID: <3757b77d.14818678@forums.borland.com> X-Deja-AN: 485329738 Content-Transfer-Encoding: 7bit Organization: Another Netscape Collabra Server User Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language