I am trying to resize my image to fit my java screen but i keep getting this error "Syntax error on token ";", , expected "
There isnt much to the code either:
import java.awt.Image;
import javax.swing.ImageIcon;
public class Images
{
ImageIcon welcomeImage = new ImageIcon("WelcomeImage.PNG");
Image image = welcomeImage.getImage();
Image newImage = image.getScaledInstance(750, 500, java.awt.Image.SCALE_SMOOTH);//The error appears on this line
welcomeImage = new ImageIcon(newImage);
}
You need to put your code in a method, not directly in the class definition.
Try this for instance:
import java.awt.Image;
import javax.swing.ImageIcon;
public class Images
{
public static void main(String[] args) {
ImageIcon welcomeImage = new ImageIcon("WelcomeImage.PNG");
Image image = welcomeImage.getImage();
Image newImage = image.getScaledInstance(750, 500, java.awt.Image.SCALE_SMOOTH);//The error appears on this line
welcomeImage = new ImageIcon(newImage);
}
}