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...

Recommended Answers

All 4 Replies

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.

commented: He just seems to know this stuff... +2

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

Is there a way to do this w/o applets, though???

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

img = Toolkit.getDefaultToolkit().getImage("file");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.