Drop_of_Rain
asked on
for loop question
Is this correct in that loop to add kp1.wav - kp50.wav tp the buttons
onOffButton.setActionComma nd("kp" + (i + 1) + ".wav");
looprow : for (int row = 0; row < 20; row++)
{
for (int col = 0; col < 3; col++)
{
int n = (20 * col + row + 1);
if (n > 50)
{
break looprow;
}
JButton onOffButton = new JColoredButton("" + n, Color.green, Color.black);
onOffButton.addActionListe ner(this);
onOffButton.setActionComma nd("kp" + (i + 1) + ".wav");
gridPanel.add(onOffButton) ;
}
}
onOffButton.setActionComma
looprow : for (int row = 0; row < 20; row++)
{
for (int col = 0; col < 3; col++)
{
int n = (20 * col + row + 1);
if (n > 50)
{
break looprow;
}
JButton onOffButton = new JColoredButton("" + n, Color.green, Color.black);
onOffButton.addActionListe
onOffButton.setActionComma
gridPanel.add(onOffButton)
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
*sigh*
ASKER
objects TimYates answer was correct to fit the code I posted isn't that correct. I need to pay better attention. I want to be fair about this. I really try to do this.
onOffButton.setActionComma nd("kp" + n + ".wav");
looprow : for (int row = 0; row < 20; row++)
{
for (int col = 0; col < 3; col++)
{
int n = (20 * col + row + 1);
if (n > 50)
{
break looprow;
}
JButton onOffButton = new JColoredButton("" + n, Color.green, Color.black);
onOffButton.addActionListe ner(this);
onOffButton.setActionComma nd("kp" + (i + 1) + ".wav");
gridPanel.add(onOffButton) ;
}
}
Comment from TimYates
Date: 04/26/2004 12:51AM PDT
Comment
onOffButton.setActionComma nd("kp" + (i + 1) + ".wav");
should be
onOffButton.setActionComma nd("kp" + n + ".wav");
surely?
Accepted Answer from objects
Date: 04/26/2004 12:51AM PDT
Accepted Answer
for (int i=1; i<=50; i++)
{
JButton onOffButton = new JColoredButton(Integer.toS tring(i), Color.green, Color.black);
onOffButton.addActionListe ner(this);
onOffButton.setActionComma nd("kp" + i + ".wav");
gridPanel.add(onOffButton) ;
}
onOffButton.setActionComma
looprow : for (int row = 0; row < 20; row++)
{
for (int col = 0; col < 3; col++)
{
int n = (20 * col + row + 1);
if (n > 50)
{
break looprow;
}
JButton onOffButton = new JColoredButton("" + n, Color.green, Color.black);
onOffButton.addActionListe
onOffButton.setActionComma
gridPanel.add(onOffButton)
}
}
Comment from TimYates
Date: 04/26/2004 12:51AM PDT
Comment
onOffButton.setActionComma
should be
onOffButton.setActionComma
surely?
Accepted Answer from objects
Date: 04/26/2004 12:51AM PDT
Accepted Answer
for (int i=1; i<=50; i++)
{
JButton onOffButton = new JColoredButton(Integer.toS
onOffButton.addActionListe
onOffButton.setActionComma
gridPanel.add(onOffButton)
}
ASKER
modulo: Thank you very much.
ASKER
I asked for this question to be reopened again. Because Tim Yates answered the question more precise to the code I posted. I have doubled the points to reward both of you for your answers.
Thanks for all the support,
Christopher
Thanks for all the support,
Christopher
Wow!! Thanks Christopher!! :-)
I wish you all the luck in your project!!
Thanks again!!
Tim
I wish you all the luck in your project!!
Thanks again!!
Tim
ASKER
You are welcome to share your knowledge with me by answering my questions any time you get a chance to.
:-) will do :-)
ASKER
Thanks, I have them up all the time
ASKER
Date: 04/26/2004 12:51AM PDT
Accepted Answer
for (int i=1; i<=50; i++)
{
JButton onOffButton = new JColoredButton(Integer.toS
onOffButton.addActionListe
onOffButton.setActionComma
gridPanel.add(onOffButton)
}
OK I can see the difference in the code, it does make more sense.
Thanks for the support,
Christopher