This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "ActionEvent and JButton Question" Watch "ActionEvent and JButton Question" New topic

ActionEvent and JButton Question

Bear Kim

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!

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
I agree. Here's the link:
subject: ActionEvent and JButton Question
Similar Threads
how to call a new .class file in Actionlistener
JButton Syntax Question
A simple calculator help!
How to handle events in java
JApplet Problem - HELP