Results 1 to 3 of 3
  1. #1
    yoodidoo is offline Member
    Join Date
    Jul 2009
    Posts
    7
    Rep Power
    0

    Default [Resolved] How can I save items in my JList?

    I recently started programming classes, and I believe i've grasped the basics
    of JAVA. However, i haven't learned anything about saving data yet and I'd
    appreciate if someone could help me out with this.

    I'm currently working on an application I'm making for practice that keeps track
    of shows that i watch. It has a JList that stores custom objects i made.

    However, whenever I close my program, all the items I've added in my JList
    disappear. What I would like is that each time I close the program, it saves
    the items I have added/removed, and when the program is opened, it loads
    up with the previous save.

    Thanks in advance.
    Last edited by yoodidoo; 08-03-2009 at 04:14 AM. Reason: Resolved

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    There are several ways. If your JList uses a DefaultListModel, this is serializable, and you can read it and write it simply to a file as you would any other serializable object (the Sun tutorials will show you how). Otherwise you can read and write the items in the model into and out of a text file by again using the model. Again the Sun IO tutorials can show you the details on how to read and write to files.

  3. #3
    yoodidoo is offline Member
    Join Date
    Jul 2009
    Posts
    7
    Rep Power
    0

    Default

    I resolved my problem, one of my classes was missing "implements Serializable".
    Last edited by yoodidoo; 08-03-2009 at 04:14 AM. Reason: Resolved

Similar Threads

  1. How can i save the data Internally(auto save)
    By Rama Koti Reddy in forum AWT / Swing
    Replies: 2
    Last Post: 11-01-2010, 09:31 PM
  2. jlist items
    By bullstreetboy in forum New To Java
    Replies: 6
    Last Post: 04-12-2009, 06:30 PM
  3. CheckBox Jlist items
    By dropez in forum AWT / Swing
    Replies: 1
    Last Post: 03-26-2009, 08:39 PM
  4. how to save added items in jcombobox
    By kwink in forum AWT / Swing
    Replies: 2
    Last Post: 03-22-2009, 07:03 PM
  5. different sort of items
    By jrleonard in forum SWT / JFace
    Replies: 0
    Last Post: 12-23-2008, 03:41 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
  •