Created
June 3, 2018 11:42
-
-
Save bitsnaps/59755f182865d39dc90d546fe97d64ce to your computer and use it in GitHub Desktop.
Simple AWT Gui App using what looks like Builder Pattern with Groovy
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 java.awt.* | |
import java.awt.event.* | |
new Frame(title:"Hello AWT", size:[300, 200], locationRelativeTo: null, visible: true).with { | |
def tf = add({ new TextField(text:"www.google.com", bounds: [50,50,150,20])}() ) | |
def l = add({ new Label(bounds: [50,100,250,20]) }()) | |
add({ | |
def b = new Button(label:"Find IP", bounds: [50,150,60,30]) | |
b.addActionListener({ l.text = "IP of ${tf.text} is ${java.net.InetAddress.getByName(tf.text).hostAddress}" }) | |
b}()) | |
addWindowListener({ dispose() } as WindowAdapter) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment