I'm trying to write a program that will present the user with a series of words, like a poem, but individually. Each word will be linked to a specific line of music, and by positioning the words in any order, the user will also reposition the phrases of music so as to produce a unique song and poem every time. It's working well so far; I have everything functional except for one aspect: I would like for each word to be highlighted (or disappear from the screen) as its phrase of music is played. I can't seem to do this, because the only way to make it pause long enough for the complete phrase to be heard (rather than playing them all at once) is to use the Thread.sleep() function or a while loop with a millis() counter, and while either of these is happening I can't access the draw() method.
I realize it's probably impossible to tell what I'm trying to say based on my description, so I've included the section of code.
//Iterate through the song phrases, in the order that they are encountered physically on the screen
for(int i = 0; i < player.length; i++) {
/*
Hide the word associated with the current phrase. The associated method works fine on its own, but this doesn't get called until after all of the phrases have played, for some reason, when suddenly all the words vanish. I've tried adding "this.repaint()" or "this.redraw()", both of which are ineffective. After a bit of research, I've found that the draw() method can't be called itself, and redraw() doesn't actually call it, it just tags it to say that it needs to draw next time it's free to do so. Currently, what happens is it plays through all of the music and then hides all of the words.
*/
this.hide(i);
//Play the phrase, using ddf.minim.AudioPlayer player[]
player[i].play();
//Pause the program until the sound has finished playing, minus a bit, since I cut the .aiff files a little long