Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   Implementing Sounds? (http://www.programmingforums.org/showthread.php?t=7776)

bae Dec 31st, 2005 12:55 PM

Implementing Sounds?
 
How would I implement sounds to my applet along with MouseListeners?

ex. Would this work?

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.util.*;

public class Selection extends Applet implements ItemListener, MouseListener, MouseMotionListener
{-code-
...
...
}

I basically want sound to play when a user hovers his mouse over an object.



Best regards,
Ben. :banana:

alcdotcom Jan 4th, 2006 5:22 PM

How to Write a Mouse Listener

Sounds

JavaMan Jan 7th, 2006 9:27 AM

The AudioClip class uses Applets to load a music.

First declare your new AudioClip object:
:

private AudioClip sound;

Then load it:
:

sound = Applet.newAudioClip(this.getClass().getResource("sound.wav"));

When your mouse is within a region, just play the sound:
:

sound.play();

Polyphemus_ Jan 7th, 2006 9:29 AM

@Bae: use code tags next time.


All times are GMT -5. The time now is 4:33 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC