Woden501
2008-10-27 13:45:42 UTC
Basically I have a field of JButtons attached to a JPanel in a grid layout. My problem is that I don't know how to find the (x, y) position of a JButton on the grid when it is clicked. I need these coordinates because they will then be fed to my 2D array of button objects that will actually determine what is done after the JButton is clicked. I've gone through the Actionlistener, GridLayout, and JButton entries on the API, but couldn't find anything to help me. Does anyone out there have an idea of how I could find the (x, y) position in the grid for the JButton that is clicked? Or should I try to do this in a different way?
Thanks in advance for any help.