• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I add sound to my working keypress event for the spacebar?

 
Judas Styng
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My keypress events already work fine and shoot a sword when the space bar is pressed. Now I want to add sound to that already working code. I don't want to have to write a whole new class just for sound, so is that possible? This is the working code for my Zelda program:
 
Piet Souris
Rancher
Pie
Posts: 1511
32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found this answer at StackOverflow:

http://stackoverflow.com/questions/25171205/playing-sound-in-java

Seems simple to apply, although I have no experience with this.
 
Campbell Ritchie
Sheriff
Posts: 51332
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Piet Souris wrote:I found this answer at StackOverflow: . .
What about ToolKit.getDefaultToolkit().beep()? I have probably spelt that all wrongly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic