Java中的系统声音 [英] System Sounds in Java
本文介绍了Java中的系统声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编写一个错误对话框,我希望它调用正确的系统指定声音.是否可以通过Java访问系统声音(例如,启动声音,默认蜂鸣声,星号,紧急停止等)?
I'm trying to code an error dialog, and I want it to call the proper system-specified sound. Is there any way to access system sounds from Java (i.e. Startup sound, default beep, asterisk, critical stop, etc.)?
注意:我了解java.awt.Toolkit.getDefaultToolkit().beep();
推荐答案
在这里(仅限Windows:)
Here ya go (exclusively for windows:)
final Runnable runnable =
(Runnable) Toolkit.getDefaultToolkit().getDesktopProperty("win.sound.exclamation");
if (runnable != null) runnable.run();
适用于Windows的更多声音(所有页面包含相同的内容): Java 6 , Java 7 , Java 8 . (祝其他操作系统好运!)
More sounds for Windows (all pages contain the same content): Java 6, Java 7, Java 8. (Good luck finding some for other OS!)
这篇关于Java中的系统声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文