Monday, January 6, 2014

Beep from your speaker

//The following program will generate 5 beeps per 2 second.
class testforbeep
{
  public static void main(String args[])
  {
    int i;
    for(i=1;i<=5;i++)
    {
        try{Thread.sleep(2000);}catch(InterruptedException ie){}
        java.awt.Toolkit.getDefaultToolkit().beep();
    }
  }
}


To generate beep from your computer speaker, write the following code.
 
java.awt.Toolkit.getDefaultToolkit().beep();

No comments:

Post a Comment