4 Replies Latest reply on Oct 26, 2012 3:10 PM by gimbal2

    Alert Sound

      Hi every body
      i am Java Programmer but NEW in the JavaFX domain...

      Simply, i need to fire an "alert sound" somewhere in my application...
      Please help me with the SIMPLEST code ...

      suppose that i have the file "abc.mp3" in the right directory, than what i have to do in order to import it and run it...

      Many thanks for any simple useful help
        • 1. Re: Alert Sound
          See here:

          • 2. Re: Alert Sound
            Let me first thank you for your quick, simple and useful answer....

            Just, how to refer to my file in the right directory (My file : Pop.aiff, in the same directory with my Java class),

            i tried :

            AudioClip plonkSound = new AudioClip("Pop.aiff");
            AudioClip plonkSound = new AudioClip("/Pop.aiff");

            i get errors..
            while when i did :

            Image Back = new Image(getClass().getResourceAsStream("Back.jpg"));

            i can easily refer to Back.jpg without any error...
            • 3. Re: Alert Sound
              Thanks it is Okey ... i put :

              AudioClip plonkSound = new AudioClip(getClass().getResource("Pop.aiff").toString());

              and it works...

              Thanks again
              • 4. Re: Alert Sound
                Beware: you will probably want to get in the habit of using
                especially when you learn about packages and you start to use them (which you should btw). Using getClass().getResource() works for you right now, but I suggest you attempt to find the javadoc (using Google) that describes this method, as an exercise to help you learn how to find your own information.