• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Using JFileChooser instead of serialization hard coded files

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using book Head First Java pg 464

Hello all,

I am attempting to use a JFileChooser to save my beatbox data which originally was using a serializable method. I am having trouble grasping how to get a serializable object such as a Boolean that is originally coded to go directly to a hard coded file and turn into something that JFileChooser can save (the user creates the file name vs it being hard coded). Here is an example below:

The working Serialization method:



What I have tried to do with it:


Thanks in advance for any help!
 
Ranch Hand
Posts: 441
Scala IntelliJ IDE Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm a bit rusty on this, but I think you should just be using JFileChooser to get the user to specify a File object. Once you have the File, you just use that in place of the hard-coded filename string. It doesn't have anything to do with serialization per se.
 
Joe Chavis
Greenhorn
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Luigi Plinge wrote:I'm a bit rusty on this, but I think you should just be using JFileChooser to get the user to specify a File object. Once you have the File, you just use that in place of the hard-coded filename string. It doesn't have anything to do with serialization per se.



AH never thought of that. I was too busy trying to change the data to be saved instead of just changing from where the data is saved. Excellent turn around time and I thank you! Here's my resolution for future coders with a similar issue:

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know this topic is old, but just want to say thank you!
 
reply
    Bookmark Topic Watch Topic
  • New Topic