Loading buffered image
807601Mar 13 2008 — edited Mar 15 2008Hi all
I have a question relation to this excellent looking guide on images, perhaps its a very stupid question. Sorry if this is the case.
This is the mini guide I'm following: http://www.javalobby.org/articles/ultimate-image/#2
I believe i am following the steps he has provided and am very excited to see where they are leading, but i feel stumped at a fundamental level. As a student I feel i have not had the time to go as deep into Java as i would like, being thrown every which way into many subjects. I'm sure a few of you know this feeling.
Anyway I only want to get the first 2 phases working.
Here are my 2 classes as stated by the guide author including my import classes, with compiler errors given by JCreator in brackets on applicable line
=========================================================================
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage.*;
public static BufferedImage loadImage(String ref) { (error class or interface expected on this line)
BufferedImage bimg = null;
try {
bimg = ImageIO.read(new File(ref));
}
catch (Exception e) {
e.printStackTrace();
}
return bimg;
}
=========================================================================
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
public class ImageApp{
public void loadAndDisplayImage(JFrame frame) {
BufferedImage loadImg = ImageUtil.loadImage("C:/Documents and Settings/Richie/My Documents/JCreator Pro/MyProjects/loadAndDisplayImage/classes/Flowers.png"); (cannot resolve symbol variable ImageUtil)
frame.setBounds(0, 0, loadImg.getWidth(), loadImg.getHeight());
frame.setVisible(true);
Graphics2D g = (Graphics2D)frame.getRootPane().getGraphics();
g.drawImage(loadImg, null, 0, 0);
}
public static void main(String[] args) {
ImageApp ia = new ImageApp();
JFrame frame = new JFrame("Tutorials");
ia.loadAndDisplayImage(frame);
}
}
=========================================================================
So with these errors:
(error class or interface expected on this line)
(cannot resolve symbol variable ImageUtil)
I'm not sure if I'm missing a package or a class, the author says the app will work from the 1st 2 phases but not be resizable.
Appreciate any help given
R Kelly