File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What about modifying the GUI at runtime?

 
Andriy Tsykholyas
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 47
Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow!
Andres, thank you for the excellent explanation
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic