The Artima Developer Community
Sponsored Link

Java Answers Forum
playing a beep in java

3 replies on 1 page. Most recent reply: May 20, 2002 3:24 PM by Thomas SMETS

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Bart Pelsmaekers

Posts: 12
Nickname: ikken
Registered: May, 2002

playing a beep in java Posted: May 17, 2002 9:27 AM
Reply to this message Reply
Advertisement
I want my java program play a beep when an error happens

I've written a little program to test the beeping in java, but it doesn't beep at all :(

what's wrong?

import java.awt.*;

public class geluid
{
public static void main(String [] args)
{
for(int i=0;i<20;i++)
{
System.out.println("Ik piep");
Toolkit.getDefaultToolkit().beep();
try
{
Thread.sleep(10);
}
catch (Exception e)
{}
}
}
}

tnx in advantage,
Bart


Kishori Sharan

Posts: 211
Nickname: kishori
Registered: Feb, 2002

Re: playing a beep in java Posted: May 17, 2002 1:43 PM
Reply to this message Reply
Nothing is wrong. It works on my PC. I think there is something missing/problem in your audio system on your PC.

Bart Pelsmaekers

Posts: 12
Nickname: ikken
Registered: May, 2002

Re: playing a beep in java Posted: May 19, 2002 11:46 AM
Reply to this message Reply
yes but what? i am using jdk 1.4 and my os is Windows XP.

I've also tried it with jdk 1.3.0-04 but it doesn't worked either.

Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Work perfect but ... Posted: May 20, 2002 3:24 PM
Reply to this message Reply
On my machine it work perfect in Win2K on the following :
_ 1.1.8
_ 1.2.2
_ 1.3
_ 1.4
May be should you change the code like this :
package test.lang;
 
import java.awt.*;
 
public class Geluid
{
  public static void main(String [] args)
  {
    for(int i=0;i<20;i++)
    {
      System.out.println("Ik piep");
      Toolkit.getDefaultToolkit().beep();
      try
      {
          Thread.sleep(1000);
      } catch (Exception e)
      {}
    }
  }
}
The reason is : 10 / 1000 is may be too short & all the beep (actually it is more "ding" than "beep" :-) ) are not well separated.

Thomas SMETS,
SCJP2 - Brussels

p.s. :
I have no probs with dutch but could you please make sure all your code is in English only, it may bother / scare some to see some no english signs (unless tackling multilingualism & internationnalization issues)

Flat View: This topic has 3 replies on 1 page
Topic: Classes Previous Topic   Next Topic Topic: How to connect J2EE to MySQL in Win2000?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use