This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Swing App Design Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing App Design Question" Watch "Swing App Design Question" New topic
Author

Swing App Design Question

Thomas Hubschman
Ranch Hand

Joined: Sep 25, 2002
Posts: 88
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


SCJP '02, SCWCD '02, SCJD '08, SCSNB '09, SCEA '10
Alex Kravets
Ranch Hand

Joined: Jan 24, 2001
Posts: 476
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?


All right brain, you don't like me and I don't like you, but let's just do this one thing so I can get back to killing you with beer.<br /> <br />- Homer Simpson
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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.


GenRocket - Experts at Building Test Data
Harry Pfohl
Greenhorn

Joined: Apr 21, 2001
Posts: 17
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
 
 
subject: Swing App Design Question
 
Similar Threads
Tomcat and Digester class (Jakarta-Commons)
Swing Application Design
Routing servlet
JaxP with Oracle 9i
Open SSO