|
Loading and Drawing an Image in an Applet |
|
|
Loading an image in an applet can be done in its load method. After init method is called by the browser automatically at initialization of the applet, we can draw loaded image in paint method using method of the applet. Note that paint method is automatically called too whenever applet needs to be redrawn.
Image image;
public void init() {
// Load image
image = getImage(getDocumentBase(), "http://hostname/image.gif");
}
public void paint(Graphics g) {
// Draw image
g.drawImage(image, 0, 0, this);
}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.