Well, setImage needs to actually assign the image given to an instance variable, of course. Otherwise, bi, essentially, doesn't exist anymore once the setImage method is finished, of course.
And don't override paint, and definately do call this setImage from within paint or paintComponent.
Here, in pseudo code
class PhotoPanel extends JPanel {
BufImage bi;
void setImage(BufImage localBi) {
// do whatever with localBi
bi = localBi
}
void paintComponent(Graphics g) {
super.paintComponent(g);
G2D g2d = (G2D) g;
g2d.drawImage(...)
}
}
class main {
void main() {
photopanel p = new photopanel();
displayGui
askForImageURL
BufImage bi = loadImageFromURL
p.setImage(bi);
p.validate();
p.repaint();
}
}
That's all there is to it.