CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2011
    Posts
    19

    Completely copying a JPanel and everything inside it.

    Does anyone know if its possible to do this?

    I have a JPanel called squareContainer, which holds other JPanels called number, all of which have a randomly assigned image to it. Before I start removing/changing the images, I need to completely copy the state of squareContainer and what images are where, then possibly put it back later.

    Does anyone know if this is at all possible?

    Thank you.

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Completely copying a JPanel and everything inside it.

    Yes, it's possible. JPanel is serializable, so as long as everything you put in it that you want stored is also serializable, you can write it to an ObjectOutputStream for storage, and read it back in later via ObjectInputStream.

    The sole justification of teaching, of the school itself, is that the student comes out of it able to do something he could not do before. I say do and not know, because knowledge that doesn't lead to doing something new or doing something better is not knowledge at all...
    J. Barzun
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured