Last active
August 29, 2015 14:15
-
-
Save timyates/d97d613e4379434ff7a8 to your computer and use it in GitHub Desktop.
7guis counter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.geometry.Insets | |
import static groovyx.javafx.GroovyFX.start | |
start { | |
stage(title: 'Counter', show: true, onHidden:{e -> System.exit(0)}) { | |
scene { | |
hbox(spacing:10, padding:new Insets(10)) { | |
textField(id: 'count', editable: false, prefColumnCount: 10, text:'0') | |
button('count', onAction:{e -> count.text = (count.text as Integer) + 1}) | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Or, with binding: | |
import javafx.geometry.Insets | |
import groovyx.javafx.beans.FXBindable | |
import static groovyx.javafx.GroovyFX.start | |
class Model { | |
@FXBindable String clicksStr = "0" | |
private int clicks = 0 | |
def onClick = { | |
clicksStr = "${++clicks}" | |
} | |
} | |
start { | |
def model = new Model() | |
stage(title: 'Counter', show: true, onHidden:{e -> System.exit(0)}) { | |
scene { | |
hbox(spacing:10, padding:new Insets(10)) { | |
textField(id: 'count', text:bind(model.clicksStrProperty), editable: false, prefColumnCount: 10) | |
button('count', onAction:model.onClick, focused: true) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment