Groovy: различия между версиями

Содержимое удалено Содержимое добавлено
Строка 1503:
reader -> println reader.readLines()
}}
callUrl.callAsync();
}
}
</syntaxhighlight>
= GUI. SWT (Standard Widget Toolkit) =
Desktop программу можно написать на [https://ru.wikipedia.org/wiki/Standard_Widget_Toolkit SWT] - кросс-платформенную оболочку для графических библиотек конкретных платформ.
Файл-скрипт SWTExample.groovy
<syntaxhighlight lang="groovy">
@Grapes(@Grab(group='org.eclipse.swt', module='org.eclipse.swt.win32.win32.x86_64', version='4.3'))
import org.eclipse.swt.widgets.*
import org.eclipse.swt.layout.GridLayout
import org.eclipse.swt.SWT
 
def display = new Display ()
def shell = new Shell(display)
shell.setLayout(new GridLayout())
def button = new Button(shell, SWT.NONE)
button.setText("Click and check the console")
button.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
switch (e.type) {
case SWT.Selection:
println("button pressed")
break
}
}
});
//shell.setText("Snippet 1")
shell.open()
 
 
 
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ()
}
display.dispose()
</syntaxhighlight>
 
= Прочие советы =
Парсинг строки, и выполнение ее в рантайме: