| Author |
What about modifying the GUI at runtime?
|
Andriy Tsykholyas
Greenhorn
Joined: Feb 24, 2009
Posts: 15
|
|
Hi,
There are many tools for making initial GUI (e.g Matisse). But in a complex application the GUI is not static. And many of those tools simply fails to help you when it comes to modifying the GUI at runtime.
I like the Groovy approach for building the GUI. The code using SwingBuilder is clear, readable and maintainable. I also like the Griffon approach for clear separation of models, controllers and views. But what about modifying the GUI at runtime? I mean how easy/difficult is to add some new components to existing (and visible) container or remove some components from it using Griffon/Groovy.
Thanks in advance,
Andriy
|
 |
Andres Almiray
author
Ranch Hand
Joined: Jan 25, 2010
Posts: 46
|
|
It's very simple as long as you keep a reference to the container (though you can locate a container easily using Groovy too). Take for example Griffon View taken from the Book's source repository (http://code.google.com/p/griffoninaction/source/browse/#svn/trunk/chap01)
The tabGroup id: property sets a variable on the current builder. Any code can refer to that JTabbedPane by using that variable name. On a controller we have this
Notice the controller has a 'view' property. Views share variables with the builder that created them, in our case it shares the tabGroup variable. Calling createMVCGroup() with those settings embeds a new tab into the tabGroup tabbedPane.
Another way to do it would be using the builder explicitly from within the controller
Cheers,
Andres
|
 |
Andriy Tsykholyas
Greenhorn
Joined: Feb 24, 2009
Posts: 15
|
|
Wow!
Andres, thank you for the excellent explanation
|
 |
 |
|
|
subject: What about modifying the GUI at runtime?
|
|
|