title: paintComponent on JPanel, image flashes and then disappears
body: <p>I have a JApplet (MainClass extends JApplet), a JPanel (ChartWindow extends JPanel) and a Grafico class.</p>
  
  <p>The problem is that the Grafico class instance has 2 JPanel that should show 2 images (1 for each panel) but the images are shown and after a little while they disappears: instead of them i get a gray background (like an empty JPanel). This happens for every repaint() call (that are made in the ChartWindow class)</p>
  
  <p>the MainClass <code>init()</code> contains</p>
  
  <pre><code>chartwindow=new ChartWindow();
  add(chartwindow)
  </code></pre>
  
  <p>chartwindow has a Grafico instance.</p>
  
  <p>it's the ChartWindow's <code>paintComponent</code> (override)</p>
  
  <pre><code>paintComponent(Graphics g)
  {
      super.paintComponent(g);
      Image immagineGrafico=createImage(grafico.pannelloGrafico.getWidth()
            ,grafico.pannelloGrafico.getHeight()); 
       Image immagineVolumi=createImage(grafico.pannelloVolumi.getWidth()
        ,grafico.pannelloVolumi.getHeight());
    Graphics2D imgGrafico=(Graphics2D)immagineGrafico.getGraphics();
    Graphics2D imgVolumi=(Graphics2D)immagineVolumi.getGraphics();
    grafico.draw(imgGrafico,imgVolumi,mouseX,mouseY);
  
    ((Graphics2D)grafico.pannelloGrafico.getGraphics()).drawImage(immagineGrafico,0,0,this);
    ((Graphics2D)grafico.pannelloVolumi.getGraphics()).drawImage(immagineVolumi,0,0,this);
  }
  </code></pre>
  
  <p>grafico's JPanels are added this way in the ChartWindow's constructor</p>
  
  <pre><code>grafico=new Grafico()
  ................
  add(grafico.pannelloGrafico);
  add(grafico.pannelloVolumi);
  </code></pre>
  
  <p>Tell me if you need more information, thank you very much :-)</p>