Return the index of clicked button?

前端 未结 4 719
执笔经年
执笔经年 2020-12-02 02:47

I have got an array of 30 buttons []. I have a variable buttonClicked. When I press the button how can I get the index and store the index number in the buttonClicked?

4条回答
  •  我在风中等你
    2020-12-02 03:20

    You can find the button in ActionEvent.getSource(). To find the index it is just a matter of iterating through the array, looking for that particular button.

提交回复
热议问题