Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Teddy's q&a

807598Jan 16 2006 — edited Feb 1 2006
Hi again guys... I thought it'd be pretty stupid of me that whenever I would run into a problem I would make a new thread about it. Hence, this is the only thread I am ever going to post in regarding my own questions.

I would like to start off with a small question. I have the following:
    private int getButtonIndex(Object o)
    {
        for(int i=0;i<b.length;i++)
        {
            if(b==o)
{
return i;
}
}

return -1;
} //Just wrote this to clarify, has nothing to do with my problem

public void actionPerformed(ActionEvent e)
{
int buttonIndex = getButtonIndex(e.getSource());
if(buttonIndex>-1 && buttonIndex<24)
{
this.s[buttonIndex].play();
guitarstring[0]=s[buttonIndex];
}
}

Now this code works perfectly. However, I want that whenever I play a sound (this.s[buttonIndex].play();) I want all other sounds that might be playing to stop playing. Is this possible? Thanks in advance!

/Teddy
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 1 2006
Added on Jan 16 2006
140 comments
303 views