Skip to content

Instantly share code, notes, and snippets.

@bitsnaps
Created December 27, 2016 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitsnaps/243ab1fd0ecb758fa285bb0c9808e601 to your computer and use it in GitHub Desktop.
Save bitsnaps/243ab1fd0ecb758fa285bb0c9808e601 to your computer and use it in GitHub Desktop.
Simple LoginForm using GroovyFX
/**
* Original JavaFX tutorial:
* http://docs.oracle.com/javafx/2/get_started/form.htm
* Tested using JDK8
*/
@Grab('org.codehaus.groovyfx:groovyfx:0.4.0')
//@GrabExclude('org.codehaus.groovy:groovy-all')
import static groovyx.javafx.GroovyFX.start
start {
stage(title: 'Login Form',width: 300, height: 275, show: true) {
scene(width: 500, height: 250) {
gridPane(style: "-fx-background-color: burlywood", hgap:10, vgap:10, alignment:CENTER, padding:[25,25,25,25]) {
text('Welcome', row:0, column:0, font:'20px Tahoma')
label('User Name:', row:1, column:0)
textField(row:1, column:1)
label('Password:', row:2, column:0)
passwordField(row:2, column:1)
txt = text('Please sign in', column:1, row:6)
hbox(padding:10, alignment:BOTTOM_RIGHT, column:1, row:4){
button('Sign in', onAction: {e -> txt.setFill(FIREBRICK); txt.setText('Sign in button')})
button('Quit', onAction: {System.exit(0)})
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment