Results 1 to 5 of 5
  1. #1
    mad72584 is offline Member
    Join Date
    Aug 2011
    Location
    Bogotá
    Posts
    28
    Rep Power
    0

    Default Save a JPanel in NetBeans 7.0.1

    Hi, How can I to save a JPanel I using? I want to save this Jpanel and can load it in the future. This JPanel contains a matrix of JButtons and other one of JLabels, the JButtons changes its own text and the text of the JLabels too. Then, I want reload the Jpanel for I can work on it. I've read about "Serialization" in java but I don't understand yet.
    Last edited by mad72584; 08-15-2011 at 03:18 PM.

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default

    hello, you don't need to serialize the whole jpanel but you can read each jlabel text with the method getText() and than save it as String. For this you can use a PrintWriter : PrintWriter*«*File*«*Java Tutorial. When the jpanel is build, you can read the labels from your file with example a FileReader*«*File*«*Java Tutorial and set the labels with the method setText()

  3. #3
    mad72584 is offline Member
    Join Date
    Aug 2011
    Location
    Bogotá
    Posts
    28
    Rep Power
    0

    Default

    Thanks! It looks easy, I'll read it and test it and I'll coment you. Meanwhile, I wait for more options. Thanks j2me64.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    Another possibility is the XMLEncoder and XMLDecoder classes.

  5. #5
    mad72584 is offline Member
    Join Date
    Aug 2011
    Location
    Bogotá
    Posts
    28
    Rep Power
    0

    Default

    Ok. thanks, I've done it with PrintWiter and FileReader. Thanks j2me64. I'm studing XMLEncoder Norm, Thanks you too.

Similar Threads

  1. Trouble adding JPanel to JFrame with NetBeans IDE
    By ozzyman in forum New To Java
    Replies: 1
    Last Post: 05-23-2011, 10:35 PM
  2. jpanel not showing up under inspector in netbeans
    By pink123 in forum AWT / Swing
    Replies: 3
    Last Post: 03-31-2011, 03:39 AM
  3. Replies: 1
    Last Post: 11-09-2010, 09:28 AM
  4. How can I add image to a JPanel using netbeans
    By shahid0627 in forum AWT / Swing
    Replies: 5
    Last Post: 09-01-2009, 07:56 AM
  5. Replies: 4
    Last Post: 08-28-2009, 06:50 PM

Tags for this Thread

Posting Permissions

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