is there anyone how can help me with image icons please?
Hey
I am just playing around with loading up images and seem to of hit a wall!
Here is the main class
Code:
import javax.swing.JFrame;
public class mainTests {
public static void main(String[] args) {
RandomStuff image;
JFrame main = new JFrame("main");
main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
image = new RandomStuff();
main.getContentPane().add(image);
main.setSize(300,300);
main.setVisible(true);
}
}
and here is the class i want to load an image from:
Code:
import java.awt.*;
import javax.swing.*;
public class RandomStuff extends JPanel{
public void paintComponent(final Graphics2D g) {
Image test = new ImageIcon("C:\\Documents and Settings\\main.user\\My Documents\\My Pictures\\autobots_logo_sm.jpg").getImage();
g.drawImage(test,10,10,this);
}
}
Does anyone have any idea why this is not working please ?