I am making a game and need a hell of alot of varibles. it is all so GUI so I need alot of Jbuttons. can I do it like something what I have below???

char[] mine=new char[3];
for(int count=0;count<10;count++){
//String add = "one"+count;
JButton mine[count] = new JButton("");
}

heres the error

C:\Documents and Settings\Adam\Desktop\work\MineSweep.java:42: mine is already defined in MineSweep()
final JButton mine[count] = new JButton("");

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();
}

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.