Results 1 to 9 of 9
  1. #1
    adelfa is offline Member
    Join Date
    Nov 2010
    Posts
    6
    Rep Power
    0

    Default Toolkit.getDefaultToolkit().beep() does not work

    Why Toolkit.getDefaultToolkit().beep() does not work in built-in speakers or in motherboard buzzers but it works if external speakers are connected? If I will disconnect the external speakers it really wont work. Any ideas?

  2. #2
    berkeleybross's Avatar
    berkeleybross is offline Senior Member
    Join Date
    Feb 2010
    Location
    England
    Posts
    187
    Rep Power
    5

    Default

    the default toolkit beep uses the os system alert, not the mother board beep.

    if you out put the ascii bell (no. 7) to the command line (system.out.println) you should get a beep on the mother board

  3. #3
    adelfa is offline Member
    Join Date
    Nov 2010
    Posts
    6
    Rep Power
    0

    Default

    Ah okay thanks for the information. I forgot to tell but I also tried your suggestion but still no beep at all. What could be the problem?

  4. #4
    berkeleybross's Avatar
    berkeleybross is offline Senior Member
    Join Date
    Feb 2010
    Location
    England
    Posts
    187
    Rep Power
    5

    Default

    what os are you using?
    can u normally here the beep from other programs?

    if you put "echo ^G" into a terminal / command prompt you should hear it
    (^g achieved by holding ctrl + g)

  5. #5
    adelfa is offline Member
    Join Date
    Nov 2010
    Posts
    6
    Rep Power
    0

    Default

    Ahm Windows. Yes I heard the beep.

  6. #6
    berkeleybross's Avatar
    berkeleybross is offline Senior Member
    Join Date
    Feb 2010
    Location
    England
    Posts
    187
    Rep Power
    5

    Default

    ok...
    whats the code your using to try and generate the beep?
    post it here

    and is there any output at all to command line?

  7. #7
    adelfa is offline Member
    Join Date
    Nov 2010
    Posts
    6
    Rep Power
    0

    Default

    Here's the code:

    if (product == null) {
    System.out.println("beep here");//debug
    //Toolkit.getDefaultToolkit().beep();

    //System.out.print( '\u0007' );
    //System.out.print( (char)0x07 );

    System.out.println("\007");
    System.out.flush();

    javax.swing.JOptionPane.showMessageDialog(null, "Product does not exists");

    }

    There is no output when I print character 7.

  8. #8
    berkeleybross's Avatar
    berkeleybross is offline Senior Member
    Join Date
    Feb 2010
    Location
    England
    Posts
    187
    Rep Power
    5

    Default

    Java Code:
    System.out.print("\007");
    System.out.flush();
    should work when you run it in command prompt.
    however, It doesnt work in netbeans, it just prints a space - not sure why.

    Did you run that program in an IDE or from command prompt?

  9. #9
    adelfa is offline Member
    Join Date
    Nov 2010
    Posts
    6
    Rep Power
    0

    Default

    IDE. So would that means the problem is the IDE? Okay might as well try in the command prompt.

Similar Threads

  1. Sun Toolkit
    By David55 in forum Sun Java Wireless Toolkit
    Replies: 7
    Last Post: 05-07-2009, 06:04 PM
  2. about SWT toolkit
    By MarkWilson in forum New To Java
    Replies: 2
    Last Post: 10-17-2008, 07:03 PM
  3. Java ME beep(frequency, time)
    By Morfmor in forum New To Java
    Replies: 2
    Last Post: 08-28-2008, 10:34 PM
  4. Beep
    By JavaLerner in forum New To Java
    Replies: 3
    Last Post: 07-16-2008, 10:17 AM
  5. How to beep every 5 minutes in Java
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-16-2008, 10:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •