0

Does anyone know how to draw an image or play a sound from file? I imagine there is (are) a library (libraries), but I can't find them...

2
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by jasimp
1

Is this what you mean?

Image a;
public void init() {
a = getImage(getDocumentBase(), "a.jpg"); 
}
public void paint(Graphics g){
g.drawImage(a, x, y, width, height, this);
}
AudioClip a;
public void init() {
a = getImage(getDocumentBase(), "a.wma"); 
a.play();
}

You need to make sure the files are in the same package.

Votes + Comments
He just seems to know this stuff...
0

Image and AudioClip classes can be used in Java...BRILLIANT!!!
Thanks, jasimp, you're a geenius!!!

-1

I am more familiar with Applets but this should help with sound and to get an Image use

img = Toolkit.getDefaultToolkit().getImage("file");
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.