You've defined "mine" twice.
char[] mine
JButton mine
which is it?
int count = 10
JButton[] guiButtons = JButton[count];
for(int i=0; i<count;i++)
{
guiButtons[i] = new JButton();
}
Phaelax
Practically a Posting Shark
858 posts since Mar 2004
Reputation Points: 92
Solved Threads: 51
First of all, that wont work..Plus the array would be indexed out of bounds if it did. What are you trying to do with the chars? If I knew, I could give you some better code:
JButton[] myButtons = new JButton[10];
char mine = '*';
for (int i=0; i<myButtons.length; i++)
{
myButtons[i] = new JButton(" ");
myButtons[i].addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
//choose three buttons you want as bombs
if (ae.getSource() == myButtons[0])
{
myButtons[0].setText(mine + "");
}
else if (ae.getSource() == myButtons[1])
{
myButtons[1].setText(mine + "");
}
else if (ae.getSource() == myButtons[2])
{
myButtons[2].setText(mine + "");
}
}
I guess that's something like what your wanting...If it's not, give me some more information, and I can help some more.
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20