• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Swing App Design Question

 
Thomas Hubschman
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
If I want to dyamically build a GUI from an XML file where the number of containers will not be known untill runtime, what is the best method for tracking them? I currently am adding the created containers to a hash map. With a key deliminated in the XML file.
Is this a good solution? Are there better ways?
Many thanks.
Tom
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you can store your containers in any collections you want: arrays, hashes, Vectors etc. It all comes down to which one is the fastest. Don't you think so?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As an exercise, I'm building something myself to specify a Swing GUI in XML. If a name='aname' attribute is found on any component I put it into a Map. I can create the UI and then get or set values for any of the components. I can also create a listener or model component and reference it by Map key in multiple components.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you seen:
http://www.swixml.org/
http://www.jeasy.de/
Even if you want to design your own and not use those, they should be able to give you some hints as to the best methods to use.
 
Harry Pfohl
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
see how it is done in JEasy. The hole GUI is stored in XML. To build panels and other components dynamically, JEasy offers a XML-Syntax to create new compnentns at runtime.
To test it, run the Example from www.jeasy.de and chose the tabbedpane dynamic panel. Change the xml string at the left and build a form.
Harry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic