I want to put the value of a variable (==i) in a textfield, so that its value is shown in the textfield, i.e., changing from 1 to 10.
def sb = new SwingBuilder()
def th = Thread.start {
    for(i in 1..10) {
        sleep 2000
    }
}
def Pan = sb.panel(layout: new BorderLayout()) {
    sb.panel(constraints: BorderLayout.NORTH){
        gridLayout(cols: 2, rows: 3)
        textField id:'tf', text: ?
    }
}
				
                        
You can do that with the
doOutsidemethod ofSwingBuilder, which allows to run a closure outside the EDT. The code below does what you are trying to do (with a table layout instead of a grid layout).