render JFrame to image

Discussion in 'Java' started by Soeren Meyer-Eppler, Jan 14, 2005.

  1. 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

    --
    www.BuschnicK.net
     
    Soeren Meyer-Eppler, Jan 14, 2005
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lau Lei Cheong

    Page.Render do not render complete page

    Lau Lei Cheong, May 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,345
    Lau Lei Cheong
    May 15, 2004
  2. Ahsan Rabbani
    Replies:
    1
    Views:
    5,667
    Andrew Thompson
    Jan 31, 2004
  3. helena

    drawing image on jframe

    helena, Oct 26, 2004, in forum: Java
    Replies:
    3
    Views:
    11,173
    helena
    Oct 27, 2004
  4. Laszlo Zsolt Nagy
    Replies:
    1
    Views:
    1,859
    Kartic
    Jan 26, 2005
  5. jakester
    Replies:
    3
    Views:
    2,140
    jakester
    Apr 3, 2007
  6. ChunkyLoverFTW
    Replies:
    0
    Views:
    1,078
    ChunkyLoverFTW
    Jan 4, 2011
  7. Glenn Gillen
    Replies:
    0
    Views:
    496
    Glenn Gillen
    Nov 17, 2006
  8. Replies:
    2
    Views:
    705
    markspace
    Aug 27, 2012
Loading...