render JFrame to image

  • Thread starter Soeren Meyer-Eppler
  • Start date
S

Soeren Meyer-Eppler

Hi everybody,
I'm new to Java programming and have two questions:

1) what is the difference between the Component methods paint, paintall,
print, printall?

2) How can I render a Component to an Image without showing it on
screen? I've tried the following code, which does render the JFrame to
the image, but only when I do a setVisible( true ) beforehand. I don't
want that because that causes it to be displayed on screen as well.

m_Frame = new JFrame();
// [omitted] add some stuff to the frame...
m_Frame.setVisible( true );
m_Image = new BufferedImage((int)getWidth(), (int)getHeight(),
BufferedImage.TYPE_INT_RGB );
m_Frame.paintAll( m_Image.createGraphics());


regards,

Sören
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top