7 Replies Latest reply: Jun 11, 2010 1:32 PM by DarrylBurke RSS

    Toolkit.beep() not working

    794330
      We've been trying to get a beep out of our Systems.
      Toolkit.beep() remains silent...

      We're running WinXP machines, and the Default Beep IS set to a valid sound file, and other programs beep just fine.

      Any suggestions on how to get this to work? I figure there must be some setting somewhere that I'm missing...
        • 1. Re: Toolkit.beep() not working
          843807
          check your mixer settings and make sure there aren't any muted inputs.
          • 2. This Thread is now moved
            DarrylBurke
            Note: This thread was originally posted in the [Java Programming|http://forums.sun.com/forum.jspa?forumID=31] forum, but moved to this forum for closer topic alignment.
            • 3. Re: Toolkit.beep() not working
              793415
              CasaDelGato wrote:
              We've been trying to get a beep out of our Systems.
              Toolkit.beep() remains silent...
              My apps. have never had the need for the beep() method so I am not that familiar with it, but now I've heard it mentioned twice in a week. Maybe it is a new bug.

              See [Java doesn't beep|http://forums.sun.com/thread.jspa?threadID=5441256] for a possible work-around.
              • 4. Re: Toolkit.beep() not working
                843807
                Also, if you don't mind using a teeny amount of Swing as opposed to AWT, there's always:
                UIManager.getLookAndFeel().provideErrorFeedback(null);
                The doc states that the default implementation beeps, and it's always worked for me. Note that the parameter can be null or a Component; I imagine that in theory the LookAndFeel could do more than just beep, such as make the Component flash or glow or some other fancy effect to draw attention to itself, but I've never noticed anything other than a beep, so the parameter isn't too important.
                • 5. Re: Toolkit.beep() not working
                  DarrylBurke
                  Also, if you don't mind using a teeny amount of Swing as opposed to AWT, there's always:
                  Should't make a difference.
                  // javax.swing.plaf.metal.MetalLookAndFeel
                      public void provideErrorFeedback(Component component) {
                       super.provideErrorFeedback(component);
                      }
                  
                  // javax.swing.LookAndFeel
                      public void provideErrorFeedback(Component component) {
                       Toolkit toolkit = null;
                       if (component != null) {
                           toolkit = component.getToolkit();
                       } else {
                           toolkit = Toolkit.getDefaultToolkit();
                       }
                       toolkit.beep();
                      } // provideErrorFeedback()
                  db
                  • 6. Re: Toolkit.beep() not working
                    843807
                    DarrylBurke wrote:
                    Also, if you don't mind using a teeny amount of Swing as opposed to AWT, there's always:
                    Should't make a difference.
                    Thanks Darryl. Interestingly, the WindowsLookAndFeel promises to "flash the caption bar of the active window" under certain conditions, but its implementation doesn't seem to support this (it extends BasicLookAndFeel):
                         public void provideErrorFeedback(Component component) {
                          super.provideErrorFeedback(component);
                         }
                    To the OP: Very strange, but FWIW the beep works for me on Windows XP, 6u20.

                    EDIT: Unless the Windows Toolkit implementation flashes the caption bar when beep() is called on it, which I'm betting is the case!
                    • 7. Re: Toolkit.beep() not working
                      DarrylBurke
                      I wonder if the OP is expecting the beep to come out the motherboard piezo buzzer as it used to in DOS. Doesn't work that way nowadays, you have to have a sound card / onboard sound and speakers/headphones/whatever.

                      I get the same "ding" whether I use the default Metal LaF or the System LaF (Windows7). And no, the title bar doesn't flash.

                      db