• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using a xml file to store gui constants  RSS feed

 
Bobby Anderson
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Thanks,
Billy
 
Paul Clapham
Sheriff
Posts: 22835
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!