I have a Java application using SWT as a toolkit and am tired of all the ugly code table code needed to update a GUI element.
Just to set the disabled button to enable, I need to go through something like this:
shell.getDisplay().asyncExec(new Runnable() {
public void run() {
buttonOk.setEnabled(true);
}
});
I prefer my source code to be as flat as possible, but I need a whopping 3 levels of indentation to make something simple.
Is there any way to wrap it? I need a class like:
public class UIUpdater {
public static void updateUI(Shell shell, *function_ptr*) {
shell.getDisplay().asyncExec(new Runnable() {
public void run() {
}
});
}
}
And you can use it like this:
UIUpdater.updateUI(shell, buttonOk.setEnabled(true));
Something like this would be great in order to hide this terrible mess, which apparently seems to need to be done.
, Java . Java 7 - Closures, , . - , , ?
, , Swing, - SWT.