Simple Java Question

Status
Not open for further replies.
From looking through the AWT libraries I don't think it's possible to load an image into a layout. I know this has to be wrong. What's the easist way to load one in. I'm a little confused because I can't find anything about standard picture formats.

http://java.sun.com/j2se/1.3/docs/api/java/awt/image/BufferedImage.html

Am I on the right track with this?

Thanks
 

anuj

Ars Legatus Legionis
10,198
Subscriptor++
you are, well, sorta.

w/ applets, the Applet superclass has the getImage() method:
code:<HR>
Code:
Image myImage = getImage(getCodeBase(), "myImage.gif");
which you can then use in your paint() method as:
code:<HR>
Code:
public void paint(Graphics screen) {
	.
	.
	.
	Graphics2D screen2D = (Graphics2D) screen;
	screen2D.drawImage(myImage, 0, 0, this);
	.
	.
	.
}<P>

I don't know much more about how you'd apply this to swing though :)
I'm not much of a java GUI programmer at all, but I hope this helps..

~A
 
Status
Not open for further replies.