Hello guys I have a problem in resizing the image in my java program here is the code:

import java.awt.*;
import java.applet.*;

public class sampleCaseStudy extends Applet {

    private Image MyImage;

    public void init()  {

        MyImage = getImage(getDocumentBase(), "manginasalmo.jpg");
       MyImage.getScaledInstance(700, 100, Image.SCALE_DEFAULT);
    }

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

the image displays but it doesnt change its size at all. Please help me with this

The method getScaledInstance is much like almost all methods that start with get because the important part of calling it is the object that it returns. If you ignore the return value, the point of calling it is lost. The image you want isn't MyImage, it is the image returned from getScaledInstance.

Calling getScaledInstance doesn't change the size of the original image, it creates a new image with the requested size, or in other words, a scaled instance of the original image.

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.