Synchronous calls inside the EDT can be achieved by calling the edt{}
method. This method is smarter than plain SwingUtilities.invokeAndWait
as it won't throw an exception if called inside the EDT, on the contrary, it will simply call the block of code it was given.Example:class MyController {
def model def action1 = {
// will be invoked inside the EDT by default (pre 0.9.2)
def value = model.value
Thread.start {
// do some calculations
edt {
// back inside the EDT
model.result = …
}
}
} def action2 = {
// will be invoked outside of the EDT by default (post 0.9.2)
def value = model.value
// do some calculations
edt {
// back inside the EDT
model.result = …
}
}
}