Created
July 27, 2009 08:18
-
-
Save timyates/156104 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When this script it run, try typing some text into the textfield with | |
// spaces in it. Then click the button (it will print out the value in | |
// the backing model -- which is right), but the textField has the wrong | |
// value in it | |
import java.beans.* | |
import java.awt.BorderLayout as BL | |
import groovy.beans.Vetoable | |
import groovy.beans.Bindable | |
import groovy.swing.SwingBuilder | |
import javax.swing.WindowConstants as WC | |
class Details { | |
@Vetoable @Bindable String aString | |
} | |
def details = new Details() | |
details.vetoableChange = { PropertyChangeEvent pce -> | |
if( pce.newValue ==~ /.*[ ]+.*/ ) { | |
throw new PropertyVetoException( "No spaces allowed", pce ) | |
} | |
} | |
SwingBuilder.build { | |
frame( title:'Login', id:'mainFrame', pack: true, show: true, defaultCloseOperation:WC.HIDE_ON_CLOSE ) { | |
panel( layout:new BL() ) { | |
label( id:'title', constraints:BL.WEST, text:"Try typing spaces to see a rendering bug?" ) | |
textField( id:'tf', text:details.aString, columns:20, constraints:BL.CENTER ) | |
bean( details, aString:bind { tf.text } ) | |
button( constraints:BL.SOUTH, action:action( name:'Click this to see the value of aString', closure:{ println details.aString } ) ) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment