Add Content to the View
The view classes contain the visual components for your application. As with the previous artifacts, copy the contents of the following snippet into its corresponding file: DemoConsoleView.
DemoConsoleView.groovy
application(title:'DemoConsole', pack:true, locationByPlatform:true) {
panel(border:emptyBorder(6)) {
borderLayout()
scrollPane(constraints:CENTER) {
textArea(text:bind(target:model, targetProperty:'scriptSource'),
enabled: bind {model.enabled},
columns:40, rows:10)
}
hbox(constraints:SOUTH) {
button("Execute", actionPerformed:controller.&executeScript,
enabled: bind {model.enabled})
hstrut(5)
label("Result:")
hstrut(5)
label(text:bind {model.scriptResult})
}
}
}复制代码The view script is a fairly straightforward SwingBuilder script. Griffon will execute these groovy scripts in context of it's UberBuilder (a composite of the SwingBuilder and whatever else is thrown in).
|