Put some logic in the loop in the run method to choose the next time to call the sound method so it is called at the desired times.
Use class variables to hold information about it and to control it...
Type: Posts; User: Norm
Put some logic in the loop in the run method to choose the next time to call the sound method so it is called at the desired times.
Use class variables to hold information about it and to control it...
When do you want to use the other values in the array?
The originally posted code used them all at once.
Remove the for loop and replace the i in [i] with a valid value.
That loop takes 13 seconds to execute. Why do you use that loop? What will the sound method do when called 54 times, one time immediately after the other?
What happens if you remove the for loop...
How can i do it ?
Are you asking how to call the sound method from the run method?
Calling one method from another method is a very common thing to do. Your code has many examples of that....
The paint() method is called by the jvm on the its EDT thread in response to a call to repaint()
You do not need a separate thread for executing paint().
Can the existing run() method call the...
You should NOT run loops that take 13 seconds to complete in the paint() method.
What is the loop supposed to do? It should be moved outside the paint() method to another thread where its execution...
The only two print outs that are important were time 3 (just before the loop) and time 5 (just after the loop) from post#15
The rest are not needed. Not need to post times inside the loop.
What...
time 5 is the important one.
What are the times at time3 and time 5?
Time 4 should print 54 times. What was the last value printed? Compare it to time 3
You computer is MUCH faster than mine. Mine takes 19 seconds to execute that loop.
The time4 - time3 is 0.2 seconds
How can that be?
Can you post the code showing where time 3 and time 4 are...
Now can you do the arithmetic to compute how loop it took for the loop to execute?
time for loop to execute = end loop time - start loop time
This is the loop I am talking about:
for(int...
Use the System class's current time method before and after the loop and take the difference.
You still have not answered this question:
How long does it take the loop at the end of the paint() method to execute?
That will be the minimum time between updates to the GUI.
How long does it take the loop at the end of the paint() method to execute? No changes will be made to the GUI while it is executing.
How do you want the code's execution changed? You need to...
How long does it take the loop at the end of the paint() method to execute? No changes will be made to the GUI while it is executing.
Please edit your post and wrap your code with code tags:
<YOUR CODE HERE>
to get highlighting and preserve formatting.
Where do you use the TImer class? I don't see it in the posted...