Guest User

Untitled

a guest
Jun 24th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. // g100pon #87 Bindable sample
  2. import static javax.swing.JFrame.EXIT_ON_CLOSE
  3. import groovy.swing.SwingBuilder
  4. import groovy.beans.Bindable
  5.  
  6. class Model {
  7. @Bindable String text
  8. @Bindable String select
  9. }
  10.  
  11. def model = new Model()
  12. def swing = new SwingBuilder()
  13.  
  14. swing.with { edt {
  15. frame(show:true, pack:true, defaultCloseOperation:EXIT_ON_CLOSE) {
  16. tableLayout {
  17. tr {
  18. td { label 'Input Text: ' }
  19. td { textField text:bind(target:model, 'text'), columns:10 }
  20. }
  21. tr {
  22. td { label 'Output Text: '}
  23. td { label text:bind(source:model, 'text') }
  24. }
  25. tr {
  26. td { label 'Select' }
  27. td { comboBox id:'cb', items:['enable', 'disable'], selectedItem: bind(target:model, 'select') }
  28. }
  29. tr {
  30. td(colspan:2) {
  31. textField text:'JGGUG Camp 2010', columns:10,
  32. enabled:bind(source:cb, sourceEvent: 'itemStateChanged', sourceValue: {
  33. model.select == 'enable'
  34. })
  35. }
  36. }
  37. }
  38. }
  39. }}
Add Comment
Please, Sign In to add comment