Loading images...
Code:
private Image loadImage (String pad){
return Toolkit.getDefaultToolkit().getImage(getClass().getResource(pad));
}
the getResource() function automatically searches for the file in your local directory, if it is not found there it will look inside the java system directories ... etc.
Short example:
Code:
public class MyPanel extends JPanel implements java.awt.image.ImageObserver{
public void paintComponent(Graphics g)
{
int x = 0;
int y = 0;
Image img = Toolkit.getDefaultToolkit().getImage(getClass().getResource("mario.gif"));
g.drawImage(img, x, y, this);
}
}
}
}