GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes Java bean Persistence  not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Java bean Persistence  not working" Watch "Java bean Persistence  not working" New topic
Author

Java bean Persistence not working

Girish Vasmatkar
Ranch Hand

Joined: Apr 24, 2008
Posts: 201
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
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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:

http://www.coderanch.com/t/416135/GUI/java/JavaBean-persistence-or-Serialization


GenRocket - Experts at Building Test Data
Girish Vasmatkar
Ranch Hand

Joined: Apr 24, 2008
Posts: 201
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

Joined: Apr 24, 2008
Posts: 201
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 --
 
GeeCON Prague 2014
 
subject: Java bean Persistence not working