Hi, It s my first time here in this great forum! Hope someone help me please. It is a simpple code that works fine. Take a look below. It plays a note when the button is clicked! The problem is: When I put the midi part of this code in a separeted Class the midi note sounds 15 times and stop working!? I do not know why.I tried many thinks. I would like to put the midi part in a different class just to take advantage of oriented language. Thanks if anyone could help!
I'm not familiar with how javax.sound works internally, but one thing that is definitely a problem with this code is that you're playing the sound from inside of the actionPerformed method. Event handlers should run (and terminate) quickly, lest they block other threads from running. So putting a Thread.sleep into an event handler is a big no-no. Start a new thread that plays the sound, and ses if that improves matters.
Since this is really not a beginner question, I'll move it to the Other Java APIs forum, where the Sound API is generally discussed.