• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get Beep Sound during error??

 
Murali Obla
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • 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
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.out.println("\007");
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Thanks for your reply Dirk,

I will try this line of code and let you know.
Regards,
Murali
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • 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
 
Lee Meador
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic