Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ActionEvent and JButton Question  RSS feed

 
Bear Kim
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm creating an interactive tic-tac-toe game using swing graphics, in which I have nine buttons for the nine squares. Is it possible to keep track of which button is pressed as an ActionEvent?
For example, I'm trying to do this: JButton buttonChosen = _____________ where the blank would be which button was clicked by the mouse.

I'd really appreciate any help, thank you!

Bear
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[actionEvent].getSource();
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!