This statement does that:
score +=5;
How will that change what is shown in the JLabel? You have to call a JLabel method to change its contents.
Type: Posts; User: Norm
This statement does that:
score +=5;
How will that change what is shown in the JLabel? You have to call a JLabel method to change its contents.
Where do you change the text being shown in the JLabel? The code sets it one time when it creates it:
scoreBoard=new JLabel("Score: " + score);
Post the code you are having problems with.
You should read the image files once before using them and NOT read them every time you use them.
Your code appears to read in the image files in two places????
Add a JLabel and change its text.
What is the value of image1 etc in the listener method when you try to use them?
You should initialize noDoubles with an invalid value.
Your use of currRand is confusing. I'd expect it to be...
Ok that sounds reasonable. Save the last one used and check it against the one generated by nextInt() to see if different. If the same, get a new one. If different use it and save for testing next...
Use some logic. What number do you want to save so you do not repeat it? When is that number known for sure? Certainly not when you get a new random number.
What about after you have determined that...
currRand = rand.nextInt(2);
noDoubles = currRand;
if(currRand==noDoubles
When will the if test every be false? You've just set the two variables =
What happens when you execute the...
Keep track of the numbers as they are generated and change it if the same as last one.
You should only load the images one time and use them in the listener.
Don't load them every call to the...
Get rid of the while() loop. Use only one label and change its icon in the timer listener method.
What parts of the code are you having problems with?
The timer?
The changing of the components being shown?