Hey, I'm creating a simple GUIBuilder that builds a GUI from a XML file. I've build it working a few times, but I don't like the design. Number 1 uses one big class that gets the File and returns two references to the mainWindow and the GUIModel. Number 2 uses a class GUIBuilder that calls methods from a class XMLFileReader to get the components out of the XMLFile. But, because the GUIBuilder adds the components one by one on the GUI and in the GUIModel, I can only call static methods in de class XMLFileReader. It works, but I'm not happy with it, because it's too big already and I use only a couple of components yet. Those are my requirements: - I must read a component from the xml file, check it's attributetype, and create the component, I also read attr's like size and position from it's child components and set them. - I must be able to get a component from the GUI on its unique id, so I need a model with an id-reference mapping(of the component). Especially because I'm gonna add some event handling later). Problem is that I always tend to functional programming (with the static methods). Maybe someone in here can give me a few hints on how to solve this.
Here's something I wrote aboutSax Parsers with little document handlers that match up with particular nodes in the XML. I used this technique to build something that read an XML definition of a Swing GUI. It has a handler for panels, another for layouts, another for buttons, etc. Each handler knows how to build a Swing object from the current node and its immediate children. I even had event listeners, but each one only listened to the immediate parent node which was kinda limiting. Hope those ideas help. [ November 18, 2003: Message edited by: Stan James ]
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
Grub de Bliek
Joined: Sep 09, 2003
It certainly does! Nice piece of work there... I'm gonna try to use this in my code. Thx!