File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes Can i get the index of which button was clicked? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Can i get the index of which button was clicked?" Watch "Can i get the index of which button was clicked?" New topic
Author

Can i get the index of which button was clicked?

Nitesh Panchal
Ranch Hand

Joined: Dec 23, 2008
Posts: 48
Hello,

Say suppose i created a Button array now when i click upon it the control goes to actionPerformed(ActionEvent e) method. Now i know that you get the source as well the string related to the button via getSource() and getActionCommand() respectively. But can i get the index of the button like which button was clicked? Thanks in advance!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
You'll need to iterate through the array and compare the event source to the button references you've stored in it.

Or you can make the index part of the command string, and extract it using string operations.


Ping & DNS - my free Android networking tools app
Nitesh Panchal
Ranch Hand

Joined: Dec 23, 2008
Posts: 48
Thanks Ulf!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can i get the index of which button was clicked?
 
Similar Threads
passing hidden field value to backing bean
How to get the url of previous page on click of browser back button
Sounds like simple issue but failing
which button is clicked
howto detect which button is click