2023-09-09 15:52:32 +03:00
|
|
|
use std, forms
|
2016-07-29 19:29:01 +03:00
|
|
|
|
|
|
|
textField = newTextField("Some text")
|
|
|
|
|
|
|
|
button = newButton("Click me")
|
|
|
|
button.onClick(def() {
|
|
|
|
println "TextField text: " + textField.getText()
|
|
|
|
textField.setText(textField.getText() + " Let's add new line")
|
|
|
|
})
|
|
|
|
|
|
|
|
window = newWindow("Text field example")
|
|
|
|
window.add(textField)
|
|
|
|
window.add(button, BorderLayout.SOUTH)
|
|
|
|
window.pack()
|
|
|
|
window.setLocationByPlatform()
|
|
|
|
window.setVisible()
|
|
|
|
|
|
|
|
textField.onAction(def() = echo("I am a TextField"))
|
|
|
|
textField.addKeyListener(def(type, event) {
|
|
|
|
println sprintf("%s %d %s",
|
|
|
|
type, event.keyCode, toChar(event.keyChar))
|
|
|
|
})
|