okay so I have an array of buttons, and at some point in the program I want to access the index of a button clicked in order to perform some calculations....so there are two options that I can think of...maybe there is a method to pull out the index (2d array) and use that...or what I've done in the meanwhile is create an extended class that adds methods like the ones in this code, but I am getting a compiler error saying that it can't find the constructor for it... for example I am creating a button using this new class and placing the string which is the text withinn the button so its not recognizing thtat constructor.....hopefully you all understand what I mean
import javax.swing.*;
public class BoggleButton extends JButton
{
private int row, col;
public void setPosition(int r, int c)
{
row = r;
col = c;
}
public int getRow()
{
return row;
}
public int getCol()
{
return col;
}
}
and I am getting that compiler error here:
newGameButton = new BoggleButton("New Game");
and this compiles but doesn't display the letters in each button:
grid[r][c] = new BoggleButton(letterArray[r][c]);