• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Using a xml file to store gui constants  RSS feed

 
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
 
Sheriff
Posts: 23710
50
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.
 
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!