Created
March 18, 2012 00:45
-
-
Save cholick/2067147 to your computer and use it in GitHub Desktop.
Groovy example from Ken Kousen, hit url using collection for params and display image in swing window
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
//useful Groovy example from SpringOne talk by Ken Kousen | |
//hit url using collection for params and display image in swing window | |
import java.awt.BorderLayout as BL | |
import javax.swing.WindowConstants as WC | |
import groovy.swing.SwingBuilder | |
import javax.swing.ImageIcon | |
def base = 'http://chart.apis.google.com/chart?' | |
def params = [cht: 'p3', chs: '400x200', chd: 't:60,40', chl: 'Hello|World'] | |
def url = base + params.collect { k, v -> "$k=$v" }.join('&') | |
SwingBuilder.build() { | |
frame(title: 'Hello, world', | |
visible: true, defaultCloseOperation : WC.EXIT_ON_CLOSE) { | |
label(icon: new ImageIcon(url.toURL()), constraints: BL.CENTER) | |
}.pack() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment