![]() |
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: |
|
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(); |
@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