Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // g100pon #87 Bindable sample
- import static javax.swing.JFrame.EXIT_ON_CLOSE
- import groovy.swing.SwingBuilder
- import groovy.beans.Bindable
- class Model {
- @Bindable String text
- @Bindable String select
- }
- def model = new Model()
- def swing = new SwingBuilder()
- swing.with { edt {
- frame(show:true, pack:true, defaultCloseOperation:EXIT_ON_CLOSE) {
- tableLayout {
- tr {
- td { label 'Input Text: ' }
- td { textField text:bind(target:model, 'text'), columns:10 }
- }
- tr {
- td { label 'Output Text: '}
- td { label text:bind(source:model, 'text') }
- }
- tr {
- td { label 'Select' }
- td { comboBox id:'cb', items:['enable', 'disable'], selectedItem: bind(target:model, 'select') }
- }
- tr {
- td(colspan:2) {
- textField text:'JGGUG Camp 2010', columns:10,
- enabled:bind(source:cb, sourceEvent: 'itemStateChanged', sourceValue: {
- model.select == 'enable'
- })
- }
- }
- }
- }
- }}
Add Comment
Please, Sign In to add comment