Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to Create Beep sound using JAVA?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 30-11-2009
Member
 
Join Date: Jan 2009
Posts: 69
How to Create Beep sound using JAVA?
  

Hi, can it be possible to create the beep sound for any error with the help of java, as we get in the Microsoft Windows XP. I wan't to do this. Please, help me to do this, if it is possible? If this possible, give me all source code as I don't know how to do this.

Reply With Quote
  #2  
Old 30-11-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
re: How to Create Beep sound using JAVA?

Hi, I think that this is quiet simple to do in java. You just want to create beep in java then just make copy-paste of the code and use it.
Code:
import java.awt.*;
public class BeepExample 
{
public static void main(String[] args) 
{
Toolkit.getDefaultToolkit().beep();
}
}
Reply With Quote
  #3  
Old 30-11-2009
Member
 
Join Date: Jan 2008
Posts: 1,515
re: How to Create Beep sound using JAVA?

Hi, you can make use of ASCII values to create beep sound in the java code. Just make use of it. And find out what you want.
Code:
import java.util.*;
public class Beep
{   
    public static void main(String[] args) 
{
    if(args[0].equals("1")) System.out.println("\007");
    if(args[0].equals("2")) System.out.println("\007\007");
    if(args[0].equals("3")) System.out.println("\007\007\007");
    if(args[0].equals("4")) System.out.println("\007\007\007\007");
    if(args[0].equals("5")) System.out.println("\007\007\007\007\007");
    if(args[0].equals("6")) System.out.println("\007\007\007\007\007\007");
    if(args[0].equals("7")) System.out.println("\007\007\007\007\007\007\007");
    if(args[0].equals("8")) System.out.println("\007\007\007\007\007\007\007\007");
}

}
Reply With Quote
  #4  
Old 30-11-2009
Member
 
Join Date: May 2008
Posts: 2,008
re: How to Create Beep sound using JAVA?

Hi, I have got the java script to create the beep. I don't know how to use it. But if you know then it will help you.

HTML Code:

Code:
<html>
<head>
<script language=javascript>
function check() 
{
document.musicApp.beep();
}
</script>
</head>
<body>
<form name=frm_test id=frm_test>
<input type=button value=BEEPJScript onclick=test()>
</form>
<applet code="Beep.class" width=100 height=100
NAME="musicApp" MAYSCRIPT>
</body>
</html>
JAVA code:

Code:
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class Beep extends Applet implements ActionListener 
{
  Button b1;

  public void init() 
{
    b1 = new Button ("BEEPJava");
    b1.addActionListener (this);
    add(b1);
  }

  public void actionPerformed (ActionEvent ae) 
{
    this.beep ();
  }

  public void beep() 
{
    this.getToolkit().beep();
  }
}
Reply With Quote
  #5  
Old 30-11-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
re: How to Create Beep sound using JAVA?

Hi, you can create the beep sound using java if you use the java.awt Class Toolkit which will provide you method abstract void beep() which Emits an audio beep. So, you can make use of this method to make the beep sound in java. Just try to implement this code in java. I think this is not that much difficult. If you get any error then just reply me, I will solve that. But, first just try it by yourself. I think you will not get any error.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to Create Beep sound using JAVA?"
Thread Thread Starter Forum Replies Last Post
Beep sound Logitech G35. Kusumakar Hardware Peripherals 6 11-06-2010 10:03 PM
Remove beep sound while recording Wasan Portable Devices 5 21-04-2010 10:32 AM
Beep sound when playing game teabag Monitor & Video Cards 6 23-03-2009 06:43 PM
Beep Sound from my PC microam_i Motherboard Processor & RAM 4 27-01-2009 12:26 PM


All times are GMT +5.5. The time now is 08:38 AM.