Home arrow static arrow Java Programming [Archive] - very simple Q !! but not for me..
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - very simple Q !! but not for me..
This topic has 2 replies on 1 page.

Posts:77
Registered: 5/4/04
very simple Q !! but not for me..  
Jun 19, 2004 10:27 AM



 
hello,

i know its a very simple Q for some people but i m not getting any solution to it...

the prob is that when i call ActionEvent by pressing two or more buttons the button that has produced the event is checked by using getActionCommand() but how can i check for two or more TextFields or TextAreas calling same ActionListener there is no getActionCommand() for TF n TA... i tried giving names to these components by using setName() n checking the components name in actionPerformed() but thats not working...

plz help me out... atleast this wud clear my basics....
 

Posts:143
Registered: 07/06/03
Re: very simple Q !! but not for me..  
Jun 19, 2004 12:30 PM (reply 1 of 2)



 
Use javax.swing.JTextField. This class has the method setActionCommand(String command)
 

Posts:4,130
Registered: 3/31/99
Re: very simple Q !! but not for me..  
Jun 19, 2004 1:05 PM (reply 2 of 2)



 
Perhaps your use of setName() was not correct - it seems like it should work.

Another alternative is to provide the ability for your ActionListener to compare the object that is the source of the event to the TextFields.

Or, use a separate ActionListener.
 
This topic has 2 replies on 1 page.