Home arrow static arrow Java Programming [Archive] - getActionCommand() and getSource()
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - getActionCommand() and getSource()
This topic has 2 replies on 1 page.

Posts:41
Registered: 4/21/02
getActionCommand() and getSource()   
Aug 6, 2004 6:48 AM



 
What is the difference between getActionCommand() and getSource() for Events? I know one returns a String and the other returns an object, but I see them used interchangeably. When would I use one over the other? Thanks!
 

Posts:1,695
Registered: 1/13/04
Re: getActionCommand() and getSource()   
Aug 6, 2004 7:05 AM (reply 1 of 2)



 
Use getActionCommand() when you want to think independently from the source objects.
Use getSource() when your subsequent actions depend on each object instance.

For example, several buttons can have the same action command... you can then treat the command
globally (like the generic 'Help' feature...)
 

Posts:41
Registered: 4/21/02
Re: getActionCommand() and getSource()   
Aug 6, 2004 7:13 AM (reply 2 of 2)



 
That makes sense, thanks!
 
This topic has 2 replies on 1 page.