• 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

How to omit component's coordinates in xml serialisation

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi colleagues,
my application uses XMLEncoder for serialisation. I would like to told to XMLEncoder not to save coordinates of my JPanel.
I found out an excellent article at http://access1.sun.com/SRDs/srd_repository/1.4_javabeans.pdf.
I followed up its idea and I was able to set up transient some properties of the standard awt or swing classes. E.g "name" property of the JPanel. But some properties I was not successful to set up transient . E.g. width, height of the JPanel.
Any ideas, how to proceed?
Thank for help.
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess you have to
a) either extend JPanel
b) or create a class which uses a JPanel.
Then you may set JPanel transient.
Of course you have to store the values you like to be serializable on your own with extra membervariables (panelName).
 
Martin Motovsky
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I receive an advice, which help me to solve the problem:
"There is a skeleton (or two) in the closet of the XMLEncoder - one of them is on bounds of a Component. All of the internal trickery is in a file called MetaData.java in the beans package. If you look in that file you'll see the hardcoded hacks for the bounds, size and location properties in the persistence delegate for a component. You can subvert this by replacing this delegate with one of your own."
I.e. something like this:
XMLEncoder e = new XMLEncoder(...);
e.setPersistenceDelegate(Component.class,new Myjava_awt_Component_PersistenceDelegate());
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic