title: Paint hidden Java swing component
body: <p>I've tried to paint component to PDF. I've got itextpdf 4.2 and everything works perfectly.
  But this works only if I make visible the frame that I've tried to render.</p>
  
  <p>The similar question that I've found is <a href="https://stackoverflow.com/questions/8008087/how-to-paint-an-invisible-jframe-elsewhere">How to paint an invisible JFrame elsewhere?</a> that has the same issue, but the solution wasn't provided in answer.</p>
  
  <p>A little of code.
  I've created a <strong>JFrame</strong> and insert main <em>view</em> that I want to render.</p>
  
  <pre><code>JFrame jframe = new ShowingFrame();
  jframe.setPreferredSize(new Dimension(PDFHelper.getOriginalWidth().intValue(), PDFHelper.getOriginalHeight().intValue()));
  jframe.setMinimumSize(new Dimension(PDFHelper.getOriginalWidth().intValue(), PDFHelper.getOriginalHeight().intValue()));
  jframe.add(view);
  jframe.setUndecorated(true);
  jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  jframe.setState(Frame.ICONIFIED);
  jframe.setState(Frame.NORMAL);
  //jframe.setVisible(true);
  </code></pre>
  
  <p>If I uncomment <code>jframe.setVisible(true)</code> than everything works.
  But user will see this frame that I want to avoid.</p>
  
  <p>So the question is: How to paint hidden control?</p>
  
  <p>Inside Swing Component.java class all paint methods first check if the component is visible:</p>
  
  <pre>
  <code>
  
      public void paint(Graphics g) {
          if (isShowing()) {
              // rest of the code...
          }
      }
  
  </code>
  </pre>
  
  <p>I've tried to create inherit class <code>ShowingFrame extends JFrame</code>, that override <strong>isShowing</strong> and always return true. But this not helps to.</p>