how to drawing images at actual sizeonce the


How to Drawing Images at Actual Size

Once the image is loaded draw it in the paint() method by using the drawImage() method like this

g.drawImage(img, x, y, io)

img is a member of the Image class that you should have already loaded in your init() method. x is the x coordinate of the upper left hand corner of the image. y is the y coordinate of the upper left hand corner of the image. io is a member of a class that implements the ImageObserver interface. The ImageObserver interface is how Java handles the asynchronous updating of an Image while it's loaded from a remote web site rather than directly from the hard drive. java.applet.Applet implements ImageObserver so for now only pass the keyword this to drawImage() to denotes in which the current applet is the ImageObserver that should be used.

A paint() method which does nothing more than draw an Image starting at the upper left hand corner of the applet might look like this

public void paint(Graphics g) {
g.drawImage(img, 0, 0, this);
}

This draws the image at the actual size of the picture.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: how to drawing images at actual sizeonce the
Reference No:- TGS0285259

Expected delivery within 24 Hours