3 Replies - 784 Views - Last Post: 15 April 2009 - 05:31 PM Rate Topic: -----

#1 NeonKingKong   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-April 09

A question regarding saving, file formats....

Posted 13 April 2009 - 02:37 PM

Hello.

I've built a java application in which the user loads a number of images into the application at run time. The application stores the path to the image. When the application needs the image it constructs a new imageicon with the path specified, when it no longer needs it it deletes it for garbage collector. When the user saves they specify a folder to save in as well as a name to save as, with JFileChooser. My main data object is serialized here with the specified name, + each image in the program is loaded and written to this location as well, with the specified name + an identifier number. When this file is loaded by the program later it will go to these images it has written when it needs them instead of the original images on disk, which may be in various places on the computer.

So when I save my program with name "Balloon" in folder "Rex" Rex will hold Balloon, as well as BalloonImage0, BalloonImage0-1, BalloonImage0-2, etc. But I would rather just have *one* file saved on disk, instead of saving multiple files to a folder. I want people to be able to move the saved document of the program as a single file, and also not to be able to delete an image in the file as they would be able to do now. So I guess I would want the folder "Rex" to look like one file.

Could anybody help me out with how to do this? I am new to java and I'm not even sure if I'm asking this the right way. Thank-you for anybody's reply.

Is This A Good Question/Topic? 0
  • +

Replies To: A question regarding saving, file formats....

#2 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: A question regarding saving, file formats....

Posted 13 April 2009 - 02:59 PM

Just have an ImageIcon array in your main class
this array will be saved as the rest of your class

You know that saving ImageIcon to disk may not be re-usable with next version of Swing
Was This Post Helpful? 0
  • +
  • -

#3 NeonKingKong   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-April 09

Re: A question regarding saving, file formats....

Posted 14 April 2009 - 07:10 PM

View Postpbl, on 13 Apr, 2009 - 01:59 PM, said:

Just have an ImageIcon array in your main class
this array will be saved as the rest of your class

You know that saving ImageIcon to disk may not be re-usable with next version of Swing


An imageicon array? Before I had been creating the imageIcons as I needed then but when I tried to save I got a java out of heap memory error. The imageicons weren't in arrays they were properties of objects I created and instantiated, left in the heap. Should I not have gotten that error?

Also I technically have been saving the images as jpgs to disk by creating a bufferedimage and writing on the the bufferedimages graphic, so I have been saving jpgs not imageicons.

Thanks.
Sumner

This post has been edited by NeonKingKong: 14 April 2009 - 07:12 PM

Was This Post Helpful? 0
  • +
  • -

#4 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: A question regarding saving, file formats....

Posted 15 April 2009 - 05:31 PM

View PostNeonKingKong, on 14 Apr, 2009 - 06:10 PM, said:

An imageicon array? Before I had been creating the imageIcons as I needed then but when I tried to save I got a java out of heap

A many millions of ImageIcon do you have ?
Suspect you had a bug, like infinite recursion, to generate this error
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1