Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Triggered actionlistener

 
mike karl
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i find out which button was pressed that triggered an actionlistener. if possible
 
Piet Souris
Rancher
Posts: 1641
36
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The easiest way is to give each button a dedicated actionlistener.
Another method would be to use the method e.getSource()
or e.getActionCommand(), where e is the ActionEvent parameter of
the actionPerformed() method.
 
mike karl
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Piet Souris wrote:The easiest way is to give each button a dedicated actionlistener.
Another method would be to use the method e.getSource()
or e.getActionCommand(), where e is the ActionEvent parameter of
the actionPerformed() method.


thank you so much, e.getSource() is what i was looking for, my problem is hard to explain but that is what i needed, thank you
 
We don't have time for this. We've gotta save the moon! Or check this out:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!