Forums Register Login
Using a xml file to store gui constants
I am new to swing so go easy on me!

I have a bunch of properties that define things like menus, options, combo boxes etc. I would like to use an xml file to load these into my gui such that new options do not require a code change.

One of my problems is that I want one property to have many children. I.E. Location property has things like name. address, etc. I really don't want to hard code this in, because i may have to add new locations. I also cannot use a property file because that is a one-to-one mapping where I need a one-to-many mapping.

Does swing have anything built in to accomplish this?

Of course Swing doesn't have anything like this, because Swing is a GUI display technology and doesn't care about data storage at all.

However I use XMLEncoder and XMLDecoder from the java.beans package to do this.
Just for the sake of a good discussion, I've used XML in the past for a very similar task. It worked, but seemed heavy. I did use XStream which seemed to ease a lot of the pain of XML for me. I've often wondered if JSON wouldn't be a lighter approach. There are a ton of json libraries, I've just never given it a shot. Just something to maybe investigate.

Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

This thread has been viewed 755 times.

All times above are in ranch (not your local) time.
The current ranch time is
Sep 20, 2018 10:05:12.