I\'m trying to build a program that utilizes a 3x3 grid of buttons (using Java Swing), so I initialize it with a GridLayout and a loop to create the buttons:
There are multiple ways to distinguish which button fired the ActionEvent:
if (e.getActionCommand().equals("Top Left")
)if (e.getSource() == buttray[0] )
)if (e.getSource().getText().equals("Top Left")
)if (e.getSource().getName().equals("Top Left")
)