aspose file tools*
The moose likes Game Development and the fly likes ActionEvent and JButton Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "ActionEvent and JButton Question" Watch "ActionEvent and JButton Question" New topic
Author

ActionEvent and JButton Question

Bear Kim
Greenhorn

Joined: Feb 25, 2012
Posts: 9
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

Joined: Jun 09, 2003
Posts: 4632
[actionEvent].getSource();
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ActionEvent and JButton Question