Computer Science Canada

Another really easy poblem but im too stupid to remember how to do it

Author:  spiderman [ Tue Apr 24, 2007 8:54 pm ]
Post subject:  Another really easy poblem but im too stupid to remember how to do it

This is a simple one but i have no idea how to do it!!! lol I want to repeat this part of my program. I know you have to use a for loop but Im not good at writing for loops can some one help me out its part of my program.

public void actionPerformed (ActionEvent e)
{
{
String name = nameTextField.getText ();
if (question11Button.isSelected () || question10Button.isSelected () || question8Button.isSelected () || question6Button.isSelected () || question1Button.isSelected ())
msgLabel.setText ("Correct ");
else if (CheckBox1.isSelected () && CheckBox2.isSelected () && CheckBox3.isSelected () && CheckBox5.isSelected () && CheckBox6.isSelected ())
msgLabel.setText ("Correct ");
else if (question12Button.isSelected () || question9Button.isSelected () || question7Button.isSelected () || question5Button.isSelected () || question4Button.isSelected () || question3Button.isSelected () || question2Button.isSelected ())
msgLabel.setText ("Wrong ");
}
}
}

Author:  richcash [ Tue Apr 24, 2007 9:49 pm ]
Post subject:  Re: Another really easy poblem but im too stupid to remember how to do it

Here is a for loop that goes from 0 to 10 by an increment of 2.
Java:
for (int i = 0; i < 11; i += 2) {
   //code
}

There is also a while loop that does something forever until a condition is met :
Java:
while (condition) {
   //code
}

the above will execute the code within forever until condition is false

As for your code, I have no idea what your trying to do and no idea why you are not using arrays. Please use a more descriptive topic title, for instance "How do you do a for loop in Java?" next time and also try to find your answer in a tutorial before posting.

Author:  ericfourfour [ Tue Apr 24, 2007 10:24 pm ]
Post subject:  RE:Another really easy poblem but im too stupid to remember how to do it

You should definitely look into arrays before you go anywhere near a GUI.


: