Drawing an Image in a JPanel



I'm using Netbeans GUI and wrote the following code to draw an Image in
a JPanel. It works fine until I switch windows and then the image is
gone.

I am aware to the paint function but I don't know how to make sure to
redraw the image inside the JPanel. I do want to be able to target it
to the JPanel borders.
Any ideas?

Many thanks
John

Here is my code, ImageCrop_Panel is a JPanel created with the GUI tool

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {


this.jFrame1.setVisible(false);

Graphics g = this.ImageCrop_Panel.getGraphics();
g.drawImage( img1, 0, 0, this );

}

.