Java equivalent of C# system.beep?

后端 未结 8 1337
半阙折子戏
半阙折子戏 2021-01-01 10:31

I am working on a Java program, and I really need to be able to play a sound by a certain frequency and duration, similarly to the c# method System.Beep, I know how to use i

8条回答
  •  时光取名叫无心
    2021-01-01 10:45

    You can use this:

    java.awt.Toolkit.getDefaultToolkit().beep();
    

    EDIT

    If you are trying to play anything of duration and with different sounds you should really look into the Java MIDI library. The default beep won't be able to meet your needs as you can't change the length of the beep.

    http://www.oracle.com/technetwork/java/index-139508.html

提交回复
热议问题