Cześć,
napisałem aplikację, która ma za zadanie rysować obrazek myszką na JPanelu (taki mini paint). LPM->rysowanie, PPM->gumka, Scroll->rozmiar ołówka, Scroll_button->czyści ekran. Moje pytanie brzmi: Jak załadować to wszystko do BufferedImage, żeby przy przesuwaniu okna lub minimalizowaniu go nie znikało mi to co narysowałem?

{
drawing_area = new JPanel();
drawing_area.setVisible(false);
drawing_area.addMouseWheelListener(new MouseWheelListener() {
public void mouseWheelMoved(MouseWheelEvent evt) {
drawing_areaMouseWheelMoved(evt);
}
});

            drawing_area.addMouseListener(new MouseAdapter() {
                public void mouseEntered(MouseEvent evt) {
                    drawing_areaMouseEntered(evt);
                }
                public void mouseExited(MouseEvent evt) {
                    drawing_areaMouseExited(evt);
                }
                public void mouseReleased(MouseEvent evt) {
                    drawing_areaMouseReleased(evt);
                }
                public void mousePressed(MouseEvent evt) {
                    drawing_areaMousePressed(evt);
                }
                public void mouseClicked(MouseEvent evt) {
                    drawing_areaMouseClicked(evt);
                }
            });
            drawing_area.addMouseMotionListener(new MouseMotionAdapter() {                  
                public void mouseMoved(MouseEvent evt) {
                    drawing_areaMouseMoved(evt);
                }
                public void mouseDragged(MouseEvent evt) {
                    drawing_areaMouseDragged(evt);
                }

            });             

        }

...

private void drawing_areaMouseDragged(MouseEvent evt) 
{

    x=evt.getX()+5;
    y=evt.getY()+50;
    if (a==1)
    {           
        Graphics2D g2 = (Graphics2D)getGraphics();

        switch (col) 
        {
        case 1:
            g2.setColor(Color.BLACK);
            break;
        case 2:
            g2.setColor(Color.RED);
            break;
        case 3:
            g2.setColor(Color.YELLOW);
            break;
        case 4:
            g2.setColor(Color.BLUE);
            break;
        case 5:
            g2.setColor(Color.GREEN);
            break;
        default:
            break;
        }

        g2.fillOval(x, y, point_size, point_size);

    }
    if (a==0)
    {           
        getGraphics().setColor(new java.awt.Color(0,255,255));          
        getGraphics().clearRect(x,y,point_size*2,point_size*2);
    }
}
private void drawing_areaMouseClicked(MouseEvent evt) 
{

}

private void drawing_areaMousePressed(MouseEvent evt) {
    int button = evt.getButton();
    if (button == MouseEvent.BUTTON3) {a=0;}
    if (button == MouseEvent.BUTTON1) {a=1;}
    if (button == MouseEvent.BUTTON2) {a=2; repaint();}
}

private void drawing_areaMouseReleased(MouseEvent evt) {

}

private void drawing_areaMouseExited(MouseEvent evt) 
{
a=2;
}

private void drawing_areaMouseEntered(MouseEvent evt)
{

}

private void drawing_areaMouseMoved(MouseEvent evt) 
{
    //System.out.println("("+evt.getX()+","+evt.getY()+")");
}

private void drawing_areaMouseWheelMoved(MouseWheelEvent evt) 
{
    int rotate = evt.getWheelRotation();
    if(rotate == -1 && point_size > 2)
        point_size--;
    if(rotate == 1 && point_size < 9)
        point_size++;
}
private void black_bActionPerformed(ActionEvent evt) {
    col = 1;

}

private void red_bActionPerformed(ActionEvent evt) {

    col = 2;
}

private void yellow_bActionPerformed(ActionEvent evt) {

    col = 3;
}

private void blue_bActionPerformed(ActionEvent evt) {

    col = 4;
}

private void green_bActionPerformed(ActionEvent evt) {

    col = 5;
}