Here is a code sample:
public class MyClass extends JPanel
{
Image img;
public MyClass(Image img) {
this.img = img;
}
...
void paintComponent(Graphics g) {
g.drawImage(img, 0, 0, this);
}
void someFunction() {
img = (Image) inputStream.getObject();
}
}
Will the paintComponent()
will also get automatically called if img
so much as receives a brand new Image
instance?
Also, is there any use to the paint()
and repaint()
methods in this context?