Java FX 2 Alert sound

前端 未结 3 593
名媛妹妹
名媛妹妹 2021-01-02 11:05

How do I play an alert sound in Java FX 2? Is there a way of using the OS default notification sound?

3条回答
  •  梦谈多话
    2021-01-02 11:58

    There is currently nothing in JavaFX itself to access the OS default alert sound (you can use JavaFX to trigger on events to play back fire and forget audioclips as well as tracked media audio like mp3s).

    There is an open feature request: RT-21634 (anybody can signup to view the jira).

    You can beep via awt:

    Toolkit.getDefaultToolkit().beep();
    

    Printing a beep character, nicely named 007 should work according to google searches, but does not on my machine - I guess it accesses a buzzer in the machine rather than the speaker system and my machine must not have the buzzer connected or enabled.

    System.out.print("\007");
    System.out.flush();
    

提交回复
热议问题