• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Can't beep()

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How does one make a Java application beep?
I've tried Toolkit.getDefaultToolkit().beep();
and it compiles and executes but makes no sound.
I am very unfamiliar with the whole Toolkit idea
so I may be doing something really dumb. Apologies
if this is not an "advanced" question!
I'm running Sun jdk 1.3 on Windoze NT 4, sp6.
Jim
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<code><pre>import java.awt.*;

public class Test {
public static void main(String[] s) {
Toolkit.getDefaultToolkit().beep();
}
}</pre></code>
That should do it, I'd think - it does on my system anyway. However my machine at work is set up with no speaker at all - the only way I can hear the beep is if I plug headphones into the audio out in back of the box. Can you hear beeps normally? E.g. go to Start -> Settings -> Control Panel -> Sounds - you should be able to play a variety of sounds on your system. If you don't hear them, you need to find a way to enable sounds on your system first.
I hope the above was useful; otherwise I have no idea.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So Jim, beep in java is not going to play through your system speaker, but throught your sound card?
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The beep() in Java should be played however a beep is normally played on your system. My work setup doesn't seem to have any sort of speaker, period - the only way I hear anything from it is by hooking something up to the audio out. I don't know anything about how it's hooked up internally.
 
reply
    Bookmark Topic Watch Topic
  • New Topic