Java: way to completely disable any Swing unwanted beeps?

后端 未结 2 857
生来不讨喜
生来不讨喜 2020-12-21 02:09

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

On some occasions there are unwanted beeps without any user intervention. No crash, application keeps

2条回答
  •  余生分开走
    2020-12-21 02:45

    In Swing you need to override the LookAndFeel as follows:

    UIManager.setLookAndFeel(new NimbusLookAndFeel() {
    
      @Override
      public void provideErrorFeedback(Component component) {
    
        // Your beep decision goes here
    
        // You want error feedback 
        super.provideErrorFeedback(component);
    
      }
    });
    

    Typically your beep decision would reference some kind of external configuration/preferences flag for your application.

提交回复
热议问题