Results 1 to 3 of 3

Thread: Saving JFrame

  1. #1
    loopsnhoops is offline Member
    Join Date
    Feb 2011
    Posts
    83
    Rep Power
    0

    Default Saving JFrame

    I am trying to save the contents of a JFrame to a file so I can access in an event.
    Any ideas?

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,807
    Rep Power
    10

    Default

    You can use the Serializable interface and the ObjectInputStream (Output) classes. Or you can simply use FileWriter to write String representations of your data to a file.

    Either way try googling an IO tutorial.

  3. #3
    Tedward is offline Member
    Join Date
    May 2011
    Posts
    10
    Rep Power
    0

    Default

    I would take the information you want to save and print/write it to a text file.

    Java Code:
    public void addUser() throws IOException
        {
         if (usern.equals(null))
         usern = getUser();
    
        NamesOutput.println(usern);
        NamesOutput.close();
        }
    The getUser() method being the return method which returns the values from the JFrame. You would have to do this for each variable/item individually though. Unless they are supposed to be in a group.
    Like... DataOutput.println(usern +" "+ userj);

Similar Threads

  1. Saving JFrame
    By loopsnhoops in forum New To Java
    Replies: 5
    Last Post: 05-27-2011, 03:51 AM
  2. Replies: 5
    Last Post: 06-14-2010, 06:10 PM
  3. Replies: 6
    Last Post: 04-12-2010, 11:33 AM
  4. Replies: 4
    Last Post: 04-22-2009, 11:02 PM
  5. Saving JFrame
    By jralexander in forum New To Java
    Replies: 7
    Last Post: 12-03-2008, 10:19 PM

Posting Permissions

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