• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java bean Persistence not working

 
Girish Vasmatkar
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello to all,

I have a Custom JPanel which I want to save state of. I am using XMLEncoder and XMLDecoder class to save and retrieve the state of my JPanel. However when i try to save the JPanel using writeObject method i get an exception



Here Admin is my JPanel which extends JPanel.

The reason I am using Java bean persistence is at some stage I am modifying the JPanel components such as adding a Jlabel with an icon etc. Now what I want is when the application is restarted these changes must be reflected. I tried Simple serialization but as i designed my JPanel using Netbeans and it is using GroupLayout so I got


The XML file that is generated after saving is as follows :


 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know the answer to your problem but you could do things a whole lot simpler if you followed my first bit of advice and use the Preferences API instead of Object Serialization:

https://coderanch.com/t/416135/GUI/java/JavaBean-persistence-or-Serialization
 
Girish Vasmatkar
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your reply Sir,

But the thing is My JPanel is very complex in that it consists of two JScrollPane and many other JPanel with as many as 100 buttons on them. Also the buttons have images which are not image files but images which are altered for our likings using MediaTracker. Also Since I want to do it fast so I thought I should go with the API I am aware of. I gone through the tutorial and am wondering how can it be applied to my situation. Can you provide me just a sample example for swing components using may be just JFrame and JPanel so that I can atleast understand how to proceed from then on.

Thanks and Regards,
-- Girish --
 
Girish Vasmatkar
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fine I have got it working using Preference API. Now what I want is when the software is uninstalled the Registry entries should be removed. Because now what is happening is even if the software is uninstalled and when it is installed again it comes up with the old JPanel... Is there Java specific way which can be used to accomplish the desired behavior or do i have to made changes in the Script?

Thanks and Regards,
-- Girish --
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic