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?
Post by:Paul Clapham
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.
Post by:Gregg Bolinger
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.
Whatever you say buddy! And I believe this tiny ad too:
Download Free Java APIs to Work with Office Files and PDF