Java:彻底禁用任何Swing不必要的哔声的方法? [英] Java: way to completely disable any Swing unwanted beeps?

查看:146
本文介绍了Java:彻底禁用任何Swing不必要的哔声的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Swing开发一个相当复杂的Java应用程序。

I am working on a fairly complex Java application using Swing.

在某些情况下,如果没有任何用户干预,会发出不必要的蜂鸣声。没有崩溃,应用程序保持正常工作,我尊重EDT规则等。

On some occasions there are unwanted beeps without any user intervention. No crash, application keeps working fine, I'm respecting the EDT rules etc.

然而在某些情况下可以听到一声嘟嘟声:我可能正在做一些愚蠢的事情触发发出嘟嘟声,但无论如何,当用户离开时,导入数据时不会发生用户操作。

Yet in some cases a beep can be heard: I may be doing something silly triggering that beep but in any case it s not a user action for it can happen upon importing data, when the user is away.

对于Java应用程序应该是否可行从来没有发出任何声音来配置它,比如为整个应用程序设置一个属性,说:不要发出一声嘟嘟声?

Is it possible, for a Java application that should never ever emit any sound to configure it, say by setting a property for the whole application that says: "dont' ever emit a beep"?

我一直在谷歌搜索那个问题,我发现有相同问题但没有答案的人发来的消息:我发现有一些黑客说有一个已知的问题,JEditorPane和使用 putProperty(IgnoreCharsetDirective,布尔。 TRUE)有助于减少不必要的哔哔声。然而,关于这个问题的信息非常稀少。

I ve been Googling for that issue and I ve found message by people having the same issue but no answer: all I found was some hack saying that there was a known issue with JEditorPane and that using a putProperty("IgnoreCharsetDirective", Boolean.TRUE) was helpful to make unwanted beeps happen less often. Yet information is very scarce on the subject.

这是一个真正的问题,因为应用程序是在计算机上需要声音的环境中使用的,但是这个Java应用程序发出的噪音是不可接受的。

It s a real issue because the application is used in an environment where the sound is needed on the computer, but this Java application emitting noise is unacceptable.

推荐答案

您的问题在Java论坛上讨论过:

Your problem is discussed on the Java Forum:

// Write a custom toolkit
public class MyToolkit extends sun.awt.windows.WToolkit 
{
  public void beep() {
  }
}

// Set this property
System.setProperty("awt.toolkit", "MyPackage.MyToolkit");

注意:使用此解决方法是泄气。你仍然应该尝试找到问题的根源。

NOTE: The use of this workaround is discouraged. You should still try to find the root of the problem.

编辑:删除了一个链接,因为Java论坛上的线程现在处于脱机状态。

Removed a link, since the thread on Java Forum is now offline.

这篇关于Java:彻底禁用任何Swing不必要的哔声的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆