作者:mobiledu2502876193 | 来源:互联网 | 2023-09-18 11:12
IwanttoalerttheuserinaSwingapplicationofcertaineventswithanoldfashionedPCSpeakerb
I want to alert the user in a Swing application of certain events with an old fashioned PC Speaker beep, since not on every PC there is a soundcard with an attached speaker. (At least on my work PC there is no speaker, with a reason. :-) How can I do this?
我想在Swing应用程序中通过旧式PC扬声器提示某些事件提醒用户,因为并非每台PC上都有一个附带扬声器的声卡。 (至少在我的工作PC上没有发言者,有理由。:-)我该怎么做?
UPDATE: java.awt.Toolkit.getDefaultToolkit().beep() seems usually to generate a sound on the soundcard. It only uses the speaker if there is no active soundcard. To print an ASCII value 7 works only if the application is launched in a terminal, which at least a Swing app usually isn't. So the question is still open.
更新:java.awt.Toolkit.getDefaultToolkit()。beep()通常似乎在声卡上生成声音。如果没有活动的声卡,它只使用扬声器。要打印ASCII值7,只有在终端中启动应用程序时才有效,至少Swing应用程序通常不会。所以问题仍然存在。
6 个解决方案