Basically i have this code
ImageIcon image = new ImageIcon(this.getClass().getResource("http://i.imgur.com/UKmK7j0.jpg")); //Image is just an example
public void paintComponent(Graphics g) {
super.paintComponent(g);
image.paintIcon(null, g, x, y);
}
but it tells me
"The method paintComponent(Graphics) is undefined for the type Object"
What am i doing wrong?? Please help me
This is most likely because you are not extending the correct class. You need to extend
JPanelor any other class that contains it in order to call this super class. Right now it is looking for thepaintComponent()method in the default super class which isObjectand there is nopaintComponent()method there.