Arun Agarwal
Posts: 5
Nickname: arunrecw
Registered: May, 2003
|
|
Re: How do we put images in an applet
|
Posted: Sep 3, 2003 5:11 AM
|
|
Hi. You can also put this code as:
Image myimg ; in init() function :
myimg = Toolkit.getDefaultToolkit().getImage(<absolutepath> );
and in paint or repaint functions you can use the same top level reference of Image class as follows:
g.drawImage( myimg, <x>, <y>, this );
here, you need to import classes appropriately. Toolkit comes from java.awt.Toolkit here. and remember one thing absolute path would not contain backward slashes, they will be forward only. for example in d drive suppose you have first.gif then you have to give "d:/first.gif" .
-Arun.
|
|