Results 1 to 5 of 5

Thread: How to Create Beep sound using JAVA?

  1. #1
    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.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    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();
    }
    }

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    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");
    }
    
    }

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    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();
      }
    }

  5. #5
    Join Date
    Apr 2008
    Posts
    2,005

    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.

Similar Threads

  1. Beep sound Logitech G35.
    By Kusumakar in forum Hardware Peripherals
    Replies: 6
    Last Post: 11-06-2010, 10:03 PM
  2. Remove beep sound while recording
    By Wasan in forum Portable Devices
    Replies: 5
    Last Post: 21-04-2010, 10:32 AM
  3. Beep sound when playing game
    By teabag in forum Monitor & Video Cards
    Replies: 6
    Last Post: 23-03-2009, 06:43 PM
  4. Beep Sound from my PC
    By microam_i in forum Motherboard Processor & RAM
    Replies: 4
    Last Post: 27-01-2009, 12:26 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,243,556.92502 seconds with 17 queries