Forum Stats

  • 3,875,872 Users
  • 2,266,977 Discussions
  • 7,912,361 Comments

Discussions

Toolkit.beep() not working

casadelgato-JavaNet
casadelgato-JavaNet Member Posts: 81
edited Jun 11, 2010 2:32PM in Abstract Window Toolkit (AWT)
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...

Comments

  • 843807
    843807 Member Posts: 46,582
    check your mixer settings and make sure there aren't any muted inputs.
  • darrylburke
    darrylburke Member Posts: 18,007
    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.
  • User_64CKJ
    User_64CKJ Member Posts: 7,279 Silver Badge
    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.
  • 843807
    843807 Member Posts: 46,582
    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.
  • darrylburke
    darrylburke Member Posts: 18,007
    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
  • 843807
    843807 Member Posts: 46,582
    edited Jun 11, 2010 1:53PM
    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!
  • darrylburke
    darrylburke Member Posts: 18,007
    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
This discussion has been closed.