• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

JList and File objects

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Could someone show me:
1) how to populate saved files created in one .java file into a Jlist created on another GUI.java file? I was thinking of putting the files into an array, then pass the array to the function that would add the elements or copy the array to the Jlist, but I am not sure that's the way to do it.
2)Also, is there a way to keep the saved files in the Jlist permanently, or somehow reread the saved files into the Jlist so that the next run of the GUI.java, the saved files are visible on the Jlist?
3)how can one delete a RandomAccessFile object which is not of File type?
Thank you.
--Tom
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For 1) are they in the same application, different Applets? different servers???
For 2) you are looking for a persistance mechanism. If it is an application, writing it out to a file and later re-reading it works. If it is an applet then you have security issues, but you could save it to a cookie, or a file if the permissions are correct.
For 3) A RandomAccessFile that is not a File??? As usual I am confused
SOOOO not many answers but lots of questions. . . .
 
tom nugent
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry for not having listed all the details. The files are on the same server, and even in the same package. I'd actually done exactly what you suggested. Also, about the RandomAccessFile, what I meant was that it's not inherited from File class, but from Object class. File class has delete() method but RandomAccessFile doesnt. Last but not least, I've come across many of your inputs on the ranch, and I thought you've been very helpful and knowledgeable to the community, and I appreciate that,and I am sure others do too.
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, thank you That brightened my day!!
Back to the questions,
1) As long as you are talking about the same session an array or vector would be fine. Just make sure something in the first file keeps a reference to the array long enough for the second GUI to pick it up.
3) When you are done "Random Accessing" a file on the hard drive close the RAF and open a new File that points at the same file on the hard drive and use the delete method.
 
reply
    Bookmark Topic Watch Topic
  • New Topic