Hi all,
Im making an app that does time tables for my kid.
I can not find away to rerun the app if the answer is right, after clicking the JButton.
Here is my code. And thank you for your help.
You would have to put the code for generating new multiplication questions in a separate method.
The code you have does pretty much everything in constructor. What you should do in a constructor is just initialize GUI components and put them on your panel. Labels for operands would be initialized with empty strings, since operands will be chosen in a separate method you are about to define.
Then you define another method (say generateNewMultiplicationQuestion()) that would contain the logic for picking random numbers from those arrays (the code you already have) and once you pick the numbers you would just setText() method to set them to labels:
This method can then be invoked each time you want to generate a new question after the answer to the current one is correct:
If you want the question to be initialized as soon as you run the application, than you would invoke the above method once at the end of your constructor.
Also note what happens when you click the button without providing an answer (or providing text as an answer).
The quieter you are, the more you are able to hear.