• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to get Beep Sound during error??

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Folks,
I wanted to give beep sound using system own inside speaker whenever my application encounters error ,but I donot want to use external speaker ,how I could do this using java.
Thanks in Advance
Murali
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
System.out.println("\007");
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know if this next one will use the system speaker. I suspect not...
java.awt.Toolkit.getDefaultToolkit().beep() ;
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the first suggestion, I've noticed that if your IDE is capturing the output, the beep won't be heard. If run from the command line, the beep is heard from the system speaker.
And I'm pretty sure the second suggestion won't play through the system speaker.
Good Luck.
 
Murali Obla
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply Dirk,

I will try this line of code and let you know.
Regards,
Murali
 
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I heard the beep when running class from command line (first method). Interesting!
Can we have other sound other than just beep?
Thanks.
Bruce
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also use a line like this:

UIManager.getLookAndFeel().provideErrorFeedback(component);

where component is the component that is generating the error. This is useful in input verifiers and such.
 
reply
    Bookmark Topic Watch Topic
  • New Topic