aspose 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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 39547
    
  27
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 - updated with new look and Ping home screen widget
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
howto detect which button is click
How to get the url of previous page on click of browser back button
Sounds like simple issue but failing
which button is clicked
passing hidden field value to backing bean