Skip to content

Instantly share code, notes, and snippets.

@cholick
Created March 18, 2012 00:45
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 cholick/2067147 to your computer and use it in GitHub Desktop.
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
//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