Ok, so I spend the better part of the last couple of days knocking out the functionality of the Musical Prodigy application I am working on. Some interesting things about this application was that while using it I realized that placing the keys in Alphabetical order was actually problematic. The problem was that people could easily guess roughly what key it should be by how high or low the pitch of the note was. In a quick work-around I jumbled the keys to make it harder to guess. Sure you can still figure it out by working out the Alphabetical order of the keys and pressing accordingly, but jumbling the keys seems to have made it less easier to guess.
Here the Java bit.
During this build I had real trouble with running the tests. At first the questions would arrive as soon as the user pressed an answer, so I had to introduce a few seconds of delay before the next question. This caused the application to being unresponsive. Next I tried running the quiz on its own thread, but the tests didn’t appear to run on it’s own thread. The problem I discovered was that when the buttons notified it’s listeners, it would call actionPerform on the EDT which would then end up trapped in the delay. It wasn’t until much experimenting later that I discovered a less the perfect work around.
I still registered the QuizController to listen for button presses, but then created a new thread and runnable class to check the answer within the actionPerformed method. This allowed the UI to keep running while the QuizController checked the answer and paused before the next question.
It’s not perfect, not by far. But at least it’s working.
Another problem I had was trying to package external files (the audio files) into the executable jar. After a bit of wasted time searching the internet I finally came up with the appropriate solution.